shithub: riscv

Download patch

ref: d18440d992243c8e2f5a866d074a597c1a03754f
parent: 07a14612a1f626716a7746000dcc4492a8648223
author: mischief <[email protected]>
date: Mon Mar 13 20:48:50 EDT 2017

gs: validate parameter is dict in .initialize_dsc_parse

gs bug 697190, upstream commit 875a0095

also check gs_alloc_struct return value from upstream commit a2afc66d

--- a/sys/src/cmd/gs/src/zdscpars.c
+++ b/sys/src/cmd/gs/src/zdscpars.c
@@ -132,11 +132,18 @@
     ref local_ref;
     int code;
     os_ptr const op = osp;
-    dict * const pdict = op->value.pdict;
-    gs_memory_t * const mem = (gs_memory_t *)dict_memory(pdict);
-    dsc_data_t * const data =
-	gs_alloc_struct(mem, dsc_data_t, &st_dsc_data_t,
-			"DSC parser init");
+    dict *pdict;
+    gs_memory_t *mem;
+    dsc_data_t *data;
+
+    check_read_type(*op, t_dictionary);
+
+    pdict = op->value.pdict;
+    mem = (gs_memory_t *)dict_memory(pdict);
+
+    data = gs_alloc_struct(mem, dsc_data_t, &st_dsc_data_t, "DSC parser init");
+    if (!data)
+        return_error(e_VMerror);
 
     data->dsc_data_ptr = dsc_init((void *) "Ghostscript DSC parsing");
     if (!data->dsc_data_ptr)