diff options
-rw-r--r-- | xps/xpsdoc.c | 17 | ||||
-rw-r--r-- | xps/xpsfont.c | 2 | ||||
-rw-r--r-- | xps/xpsgradient.c | 36 | ||||
-rw-r--r-- | xps/xpshash.c | 6 | ||||
-rw-r--r-- | xps/xpsimage.c | 10 | ||||
-rw-r--r-- | xps/xpsjpeg.c | 2 | ||||
-rw-r--r-- | xps/xpsjxr.c | 8 | ||||
-rw-r--r-- | xps/xpspath.c | 4 | ||||
-rw-r--r-- | xps/xpspng.c | 3 | ||||
-rw-r--r-- | xps/xpsresource.c | 2 | ||||
-rw-r--r-- | xps/xpstiff.c | 12 | ||||
-rw-r--r-- | xps/xpsxml.c | 12 | ||||
-rw-r--r-- | xps/xpszip.c | 13 |
13 files changed, 107 insertions, 20 deletions
diff --git a/xps/xpsdoc.c b/xps/xpsdoc.c index c4724ec71..395153954 100644 --- a/xps/xpsdoc.c +++ b/xps/xpsdoc.c | |||
@@ -26,9 +26,18 @@ xps_new_part(xps_context_t *ctx, char *name, int size) | |||
26 | xps_part_t *part; | 26 | xps_part_t *part; |
27 | 27 | ||
28 | part = xps_alloc(ctx, sizeof(xps_part_t)); | 28 | part = xps_alloc(ctx, sizeof(xps_part_t)); |
29 | if (!part) { | ||
30 | gs_throw(gs_error_VMerror, "out of memory: xps_new_part\n"); | ||
31 | return NULL; | ||
32 | } | ||
29 | part->name = xps_strdup(ctx, name); | 33 | part->name = xps_strdup(ctx, name); |
30 | part->size = size; | 34 | part->size = size; |
31 | part->data = xps_alloc(ctx, size); | 35 | part->data = xps_alloc(ctx, size); |
36 | if (!part->data) { | ||
37 | xps_free(ctx, part); | ||
38 | gs_throw(gs_error_VMerror, "out of memory: xps_new_part\n"); | ||
39 | return NULL; | ||
40 | } | ||
32 | 41 | ||
33 | return part; | 42 | return part; |
34 | } | 43 | } |
@@ -81,6 +90,10 @@ xps_add_fixed_document(xps_context_t *ctx, char *name) | |||
81 | if_debug1m('|', ctx->memory, "doc: adding fixdoc %s\n", name); | 90 | if_debug1m('|', ctx->memory, "doc: adding fixdoc %s\n", name); |
82 | 91 | ||
83 | fixdoc = xps_alloc(ctx, sizeof(xps_document_t)); | 92 | fixdoc = xps_alloc(ctx, sizeof(xps_document_t)); |
93 | if (!fixdoc) { | ||
94 | gs_throw(gs_error_VMerror, "out of memory: xps_add_fixed_document\n"); | ||
95 | return; | ||
96 | } | ||
84 | fixdoc->name = xps_strdup(ctx, name); | 97 | fixdoc->name = xps_strdup(ctx, name); |
85 | fixdoc->next = NULL; | 98 | fixdoc->next = NULL; |
86 | 99 | ||
@@ -124,6 +137,10 @@ xps_add_fixed_page(xps_context_t *ctx, char *name, int width, int height) | |||
124 | if_debug1m('|', ctx->memory, "doc: adding page %s\n", name); | 137 | if_debug1m('|', ctx->memory, "doc: adding page %s\n", name); |
125 | 138 | ||
126 | page = xps_alloc(ctx, sizeof(xps_page_t)); | 139 | page = xps_alloc(ctx, sizeof(xps_page_t)); |
140 | if (!page) { | ||
141 | gs_throw(gs_error_VMerror, "out of memory: xps_add_fixed_page\n"); | ||
142 | return; | ||
143 | } | ||
127 | page->name = xps_strdup(ctx, name); | 144 | page->name = xps_strdup(ctx, name); |
128 | page->width = width; | 145 | page->width = width; |
129 | page->height = height; | 146 | page->height = height; |
diff --git a/xps/xpsfont.c b/xps/xpsfont.c index 20968cf1c..9a19021ac 100644 --- a/xps/xpsfont.c +++ b/xps/xpsfont.c | |||
@@ -53,7 +53,7 @@ xps_new_font(xps_context_t *ctx, byte *buf, int buflen, int index) | |||
53 | font = xps_alloc(ctx, sizeof(xps_font_t)); | 53 | font = xps_alloc(ctx, sizeof(xps_font_t)); |
54 | if (!font) | 54 | if (!font) |
55 | { | 55 | { |
56 | gs_throw(-1, "out of memory"); | 56 | gs_throw(gs_error_VMerror, "out of memory"); |
57 | return NULL; | 57 | return NULL; |
58 | } | 58 | } |
59 | 59 | ||
diff --git a/xps/xpsgradient.c b/xps/xpsgradient.c index 60e1fa5eb..bf0335d5f 100644 --- a/xps/xpsgradient.c +++ b/xps/xpsgradient.c | |||
@@ -259,12 +259,20 @@ xps_create_gradient_stop_function(xps_context_t *ctx, struct stop *stops, int co | |||
259 | k = count - 1; /* number of intervals / functions */ | 259 | k = count - 1; /* number of intervals / functions */ |
260 | 260 | ||
261 | domain = xps_alloc(ctx, 2 * sizeof(float)); | 261 | domain = xps_alloc(ctx, 2 * sizeof(float)); |
262 | if (!domain) { | ||
263 | gs_throw(gs_error_VMerror, "out of memory: domain\n"); | ||
264 | return NULL; | ||
265 | } | ||
262 | domain[0] = 0.0; | 266 | domain[0] = 0.0; |
263 | domain[1] = 1.0; | 267 | domain[1] = 1.0; |
264 | sparams.m = 1; | 268 | sparams.m = 1; |
265 | sparams.Domain = domain; | 269 | sparams.Domain = domain; |
266 | 270 | ||
267 | range = xps_alloc(ctx, 6 * sizeof(float)); | 271 | range = xps_alloc(ctx, 6 * sizeof(float)); |
272 | if (!range) { | ||
273 | gs_throw(gs_error_VMerror, "out of memory: range\n"); | ||
274 | return NULL; | ||
275 | } | ||
268 | range[0] = 0.0; | 276 | range[0] = 0.0; |
269 | range[1] = 1.0; | 277 | range[1] = 1.0; |
270 | range[2] = 0.0; | 278 | range[2] = 0.0; |
@@ -274,8 +282,20 @@ xps_create_gradient_stop_function(xps_context_t *ctx, struct stop *stops, int co | |||
274 | sparams.Range = range; | 282 | sparams.Range = range; |
275 | 283 | ||
276 | functions = xps_alloc(ctx, k * sizeof(void*)); | 284 | functions = xps_alloc(ctx, k * sizeof(void*)); |
285 | if (!functions) { | ||
286 | gs_throw(gs_error_VMerror, "out of memory: functions.\n"); | ||
287 | return NULL; | ||
288 | } | ||
277 | bounds = xps_alloc(ctx, (k - 1) * sizeof(float)); | 289 | bounds = xps_alloc(ctx, (k - 1) * sizeof(float)); |
290 | if (!bounds) { | ||
291 | gs_throw(gs_error_VMerror, "out of memory: bounds.\n"); | ||
292 | return NULL; | ||
293 | } | ||
278 | encode = xps_alloc(ctx, (k * 2) * sizeof(float)); | 294 | encode = xps_alloc(ctx, (k * 2) * sizeof(float)); |
295 | if (!encode) { | ||
296 | gs_throw(gs_error_VMerror, "out of memory: encode.\n"); | ||
297 | return NULL; | ||
298 | } | ||
279 | 299 | ||
280 | sparams.k = k; | 300 | sparams.k = k; |
281 | sparams.Functions = functions; | 301 | sparams.Functions = functions; |
@@ -296,12 +316,20 @@ xps_create_gradient_stop_function(xps_context_t *ctx, struct stop *stops, int co | |||
296 | for (i = 0; i < k; i++) | 316 | for (i = 0; i < k; i++) |
297 | { | 317 | { |
298 | domain = xps_alloc(ctx, 2 * sizeof(float)); | 318 | domain = xps_alloc(ctx, 2 * sizeof(float)); |
319 | if (!domain) { | ||
320 | gs_throw(gs_error_VMerror, "out of memory: domain.\n"); | ||
321 | return NULL; | ||
322 | } | ||
299 | domain[0] = 0.0; | 323 | domain[0] = 0.0; |
300 | domain[1] = 1.0; | 324 | domain[1] = 1.0; |
301 | lparams.m = 1; | 325 | lparams.m = 1; |
302 | lparams.Domain = domain; | 326 | lparams.Domain = domain; |
303 | 327 | ||
304 | range = xps_alloc(ctx, 6 * sizeof(float)); | 328 | range = xps_alloc(ctx, 6 * sizeof(float)); |
329 | if (!range) { | ||
330 | gs_throw(gs_error_VMerror, "out of memory: range.\n"); | ||
331 | return NULL; | ||
332 | } | ||
305 | range[0] = 0.0; | 333 | range[0] = 0.0; |
306 | range[1] = 1.0; | 334 | range[1] = 1.0; |
307 | range[2] = 0.0; | 335 | range[2] = 0.0; |
@@ -311,9 +339,17 @@ xps_create_gradient_stop_function(xps_context_t *ctx, struct stop *stops, int co | |||
311 | lparams.Range = range; | 339 | lparams.Range = range; |
312 | 340 | ||
313 | c0 = xps_alloc(ctx, 3 * sizeof(float)); | 341 | c0 = xps_alloc(ctx, 3 * sizeof(float)); |
342 | if (!c0) { | ||
343 | gs_throw(gs_error_VMerror, "out of memory: c0.\n"); | ||
344 | return NULL; | ||
345 | } | ||
314 | lparams.C0 = c0; | 346 | lparams.C0 = c0; |
315 | 347 | ||
316 | c1 = xps_alloc(ctx, 3 * sizeof(float)); | 348 | c1 = xps_alloc(ctx, 3 * sizeof(float)); |
349 | if (!c0) { | ||
350 | gs_throw(gs_error_VMerror, "out of memory: c1.\n"); | ||
351 | return NULL; | ||
352 | } | ||
317 | lparams.C1 = c1; | 353 | lparams.C1 = c1; |
318 | 354 | ||
319 | if (opacity_only) | 355 | if (opacity_only) |
diff --git a/xps/xpshash.c b/xps/xpshash.c index 2acdd8c9f..cda0c55cf 100644 --- a/xps/xpshash.c +++ b/xps/xpshash.c | |||
@@ -70,7 +70,7 @@ xps_hash_new(xps_context_t *ctx) | |||
70 | table = xps_alloc(ctx, sizeof(xps_hash_table_t)); | 70 | table = xps_alloc(ctx, sizeof(xps_hash_table_t)); |
71 | if (!table) | 71 | if (!table) |
72 | { | 72 | { |
73 | gs_throw(-1, "out of memory: hash table struct"); | 73 | gs_throw(gs_error_VMerror, "out of memory: hash table struct"); |
74 | return NULL; | 74 | return NULL; |
75 | } | 75 | } |
76 | 76 | ||
@@ -81,7 +81,7 @@ xps_hash_new(xps_context_t *ctx) | |||
81 | if (!table->entries) | 81 | if (!table->entries) |
82 | { | 82 | { |
83 | xps_free(ctx, table); | 83 | xps_free(ctx, table); |
84 | gs_throw(-1, "out of memory: hash table entries array"); | 84 | gs_throw(gs_error_VMerror, "out of memory: hash table entries array"); |
85 | return NULL; | 85 | return NULL; |
86 | } | 86 | } |
87 | 87 | ||
@@ -111,7 +111,7 @@ xps_hash_double(xps_context_t *ctx, xps_hash_table_t *table) | |||
111 | old_entries = table->entries; | 111 | old_entries = table->entries; |
112 | new_entries = xps_alloc(ctx, sizeof(xps_hash_entry_t) * new_size); | 112 | new_entries = xps_alloc(ctx, sizeof(xps_hash_entry_t) * new_size); |
113 | if (!new_entries) | 113 | if (!new_entries) |
114 | return gs_throw(-1, "out of memory: hash table entries array"); | 114 | return gs_throw(gs_error_VMerror, "out of memory: hash table entries array"); |
115 | 115 | ||
116 | table->size = new_size; | 116 | table->size = new_size; |
117 | table->entries = new_entries; | 117 | table->entries = new_entries; |
diff --git a/xps/xpsimage.c b/xps/xpsimage.c index 733e4f2e0..c68aebe8b 100644 --- a/xps/xpsimage.c +++ b/xps/xpsimage.c | |||
@@ -35,6 +35,10 @@ xps_isolate_alpha_channel_8(xps_context_t *ctx, xps_image_t *image) | |||
35 | byte *sp, *dp, *ap; | 35 | byte *sp, *dp, *ap; |
36 | 36 | ||
37 | image->alpha = xps_alloc(ctx, image->width * image->height); | 37 | image->alpha = xps_alloc(ctx, image->width * image->height); |
38 | if (!image->alpha) { | ||
39 | gs_throw(gs_error_VMerror, "out of memory: image->alpha.\n"); | ||
40 | return; | ||
41 | } | ||
38 | 42 | ||
39 | for (y = 0; y < image->height; y++) | 43 | for (y = 0; y < image->height; y++) |
40 | { | 44 | { |
@@ -62,6 +66,10 @@ xps_isolate_alpha_channel_16(xps_context_t *ctx, xps_image_t *image) | |||
62 | unsigned short *sp, *dp, *ap; | 66 | unsigned short *sp, *dp, *ap; |
63 | 67 | ||
64 | image->alpha = xps_alloc(ctx, image->width * image->height * 2); | 68 | image->alpha = xps_alloc(ctx, image->width * image->height * 2); |
69 | if (!image->alpha) { | ||
70 | gs_throw(gs_error_VMerror, "out of memory: image->alpha.\n"); | ||
71 | return; | ||
72 | } | ||
65 | 73 | ||
66 | for (y = 0; y < image->height; y++) | 74 | for (y = 0; y < image->height; y++) |
67 | { | 75 | { |
@@ -250,7 +258,7 @@ xps_paint_image_brush_imp(xps_context_t *ctx, xps_image_t *image, int alpha) | |||
250 | 258 | ||
251 | penum = gs_image_enum_alloc(ctx->memory, "xps_parse_image_brush (gs_image_enum_alloc)"); | 259 | penum = gs_image_enum_alloc(ctx->memory, "xps_parse_image_brush (gs_image_enum_alloc)"); |
252 | if (!penum) | 260 | if (!penum) |
253 | return gs_throw(-1, "gs_enum_allocate failed"); | 261 | return gs_throw(gs_error_VMerror, "gs_enum_allocate failed"); |
254 | 262 | ||
255 | if ((code = gs_image_init(penum, &gsimage, false, ctx->pgs)) < 0) | 263 | if ((code = gs_image_init(penum, &gsimage, false, ctx->pgs)) < 0) |
256 | return gs_throw(code, "gs_image_init failed"); | 264 | return gs_throw(code, "gs_image_init failed"); |
diff --git a/xps/xpsjpeg.c b/xps/xpsjpeg.c index d4e2030c0..29fc375c1 100644 --- a/xps/xpsjpeg.c +++ b/xps/xpsjpeg.c | |||
@@ -129,7 +129,7 @@ xps_decode_jpeg(xps_context_t *ctx, byte *rbuf, int rlen, xps_image_t *image) | |||
129 | wlen = image->stride * image->height; | 129 | wlen = image->stride * image->height; |
130 | wbuf = xps_alloc(ctx, wlen); | 130 | wbuf = xps_alloc(ctx, wlen); |
131 | if (!wbuf) | 131 | if (!wbuf) |
132 | return gs_throw1(-1, "out of memory allocating samples: %d", wlen); | 132 | return gs_throw1(gs_error_VMerror, "out of memory allocating samples: %d", wlen); |
133 | 133 | ||
134 | image->samples = wbuf; | 134 | image->samples = wbuf; |
135 | 135 | ||
diff --git a/xps/xpsjxr.c b/xps/xpsjxr.c index 762d9c289..12cb1e16d 100644 --- a/xps/xpsjxr.c +++ b/xps/xpsjxr.c | |||
@@ -98,6 +98,10 @@ xps_decode_jpegxr_block(jxr_image_t image, int mx, int my, int *data) | |||
98 | output->bits = 8; | 98 | output->bits = 8; |
99 | output->stride = output->width * output->comps; | 99 | output->stride = output->width * output->comps; |
100 | output->samples = xps_alloc(ctx, output->stride * output->height); | 100 | output->samples = xps_alloc(ctx, output->stride * output->height); |
101 | if (!output->samples) { | ||
102 | gs_throw(gs_error_VMerror, "out of memory: output->samples.\n"); | ||
103 | return; | ||
104 | } | ||
101 | 105 | ||
102 | switch (output->comps) | 106 | switch (output->comps) |
103 | { | 107 | { |
@@ -142,6 +146,10 @@ xps_decode_jpegxr_alpha_block(jxr_image_t image, int mx, int my, int *data) | |||
142 | if (!output->alpha) | 146 | if (!output->alpha) |
143 | { | 147 | { |
144 | output->alpha = xps_alloc(ctx, output->width * output->height); | 148 | output->alpha = xps_alloc(ctx, output->width * output->height); |
149 | if (!output->alpha) { | ||
150 | gs_throw(gs_error_VMerror, "out of memory: output->alpha.\n"); | ||
151 | return; | ||
152 | } | ||
145 | } | 153 | } |
146 | 154 | ||
147 | depth = jxr_get_OUTPUT_BITDEPTH(image); | 155 | depth = jxr_get_OUTPUT_BITDEPTH(image); |
diff --git a/xps/xpspath.c b/xps/xpspath.c index 90244dd8c..0cb22e272 100644 --- a/xps/xpspath.c +++ b/xps/xpspath.c | |||
@@ -262,6 +262,10 @@ xps_parse_abbreviated_geometry(xps_context_t *ctx, char *geom) | |||
262 | int reset_smooth; | 262 | int reset_smooth; |
263 | 263 | ||
264 | args = xps_alloc(ctx, sizeof(char*) * (strlen(geom) + 1)); | 264 | args = xps_alloc(ctx, sizeof(char*) * (strlen(geom) + 1)); |
265 | if (!args) { | ||
266 | gs_throw(gs_error_VMerror, "out of memory: args.\n"); | ||
267 | return; | ||
268 | } | ||
265 | pargs = args; | 269 | pargs = args; |
266 | 270 | ||
267 | //dmprintf1(ctx->memory, "new path (%.70s)\n", geom); | 271 | //dmprintf1(ctx->memory, "new path (%.70s)\n", geom); |
diff --git a/xps/xpspng.c b/xps/xpspng.c index 632afed4a..f7a6f91d3 100644 --- a/xps/xpspng.c +++ b/xps/xpspng.c | |||
@@ -287,6 +287,9 @@ xps_decode_png(xps_context_t *ctx, byte *rbuf, int rlen, xps_image_t *image) | |||
287 | image->stride = (image->width * image->comps * image->bits + 7) / 8; | 287 | image->stride = (image->width * image->comps * image->bits + 7) / 8; |
288 | 288 | ||
289 | image->samples = xps_alloc(ctx, image->stride * image->height); | 289 | image->samples = xps_alloc(ctx, image->stride * image->height); |
290 | if (!image->samples) { | ||
291 | return gs_throw(gs_error_VMerror, "out of memory.\n"); | ||
292 | } | ||
290 | 293 | ||
291 | for (pass = 0; pass < npasses; pass++) | 294 | for (pass = 0; pass < npasses; pass++) |
292 | { | 295 | { |
diff --git a/xps/xpsresource.c b/xps/xpsresource.c index fac53b617..5843bef9f 100644 --- a/xps/xpsresource.c +++ b/xps/xpsresource.c | |||
@@ -158,7 +158,7 @@ xps_parse_resource_dictionary(xps_context_t *ctx, xps_resource_t **dictp, char * | |||
158 | { | 158 | { |
159 | entry = xps_alloc(ctx, sizeof(xps_resource_t)); | 159 | entry = xps_alloc(ctx, sizeof(xps_resource_t)); |
160 | if (!entry) | 160 | if (!entry) |
161 | return gs_throw(-1, "cannot allocate resource entry"); | 161 | return gs_throw(gs_error_VMerror, "cannot allocate resource entry"); |
162 | entry->name = key; | 162 | entry->name = key; |
163 | entry->base_uri = NULL; | 163 | entry->base_uri = NULL; |
164 | entry->base_xml = NULL; | 164 | entry->base_xml = NULL; |
diff --git a/xps/xpstiff.c b/xps/xpstiff.c index a2e18089f..28cd9f4c3 100644 --- a/xps/xpstiff.c +++ b/xps/xpstiff.c | |||
@@ -570,7 +570,7 @@ xps_expand_colormap(xps_context_t *ctx, xps_tiff_t *tiff, xps_image_t *image) | |||
570 | 570 | ||
571 | samples = xps_alloc(ctx, stride * image->height); | 571 | samples = xps_alloc(ctx, stride * image->height); |
572 | if (!samples) | 572 | if (!samples) |
573 | return gs_throw(-1, "out of memory: samples"); | 573 | return gs_throw(gs_error_VMerror, "out of memory: samples"); |
574 | 574 | ||
575 | for (y = 0; y < image->height; y++) | 575 | for (y = 0; y < image->height; y++) |
576 | { | 576 | { |
@@ -687,7 +687,7 @@ xps_decode_tiff_strips(xps_context_t *ctx, xps_tiff_t *tiff, xps_image_t *image) | |||
687 | 687 | ||
688 | image->samples = xps_alloc(ctx, image->stride * image->height); | 688 | image->samples = xps_alloc(ctx, image->stride * image->height); |
689 | if (!image->samples) | 689 | if (!image->samples) |
690 | return gs_throw(-1, "could not allocate image samples"); | 690 | return gs_throw(gs_error_VMerror, "could not allocate image samples"); |
691 | 691 | ||
692 | memset(image->samples, 0x55, image->stride * image->height); | 692 | memset(image->samples, 0x55, image->stride * image->height); |
693 | 693 | ||
@@ -935,7 +935,7 @@ xps_read_tiff_tag(xps_context_t *ctx, xps_tiff_t *tiff, unsigned offset) | |||
935 | case ICCProfile: | 935 | case ICCProfile: |
936 | tiff->profile = xps_alloc(ctx, count); | 936 | tiff->profile = xps_alloc(ctx, count); |
937 | if (!tiff->profile) | 937 | if (!tiff->profile) |
938 | return gs_throw(-1, "could not allocate embedded icc profile"); | 938 | return gs_throw(gs_error_VMerror, "could not allocate embedded icc profile"); |
939 | /* ICC profile data type is set to UNDEFINED. | 939 | /* ICC profile data type is set to UNDEFINED. |
940 | * TBYTE reading not correct in xps_read_tiff_tag_value */ | 940 | * TBYTE reading not correct in xps_read_tiff_tag_value */ |
941 | xps_read_tiff_bytes(tiff->profile, tiff, value, count); | 941 | xps_read_tiff_bytes(tiff->profile, tiff, value, count); |
@@ -950,21 +950,21 @@ xps_read_tiff_tag(xps_context_t *ctx, xps_tiff_t *tiff, unsigned offset) | |||
950 | case StripOffsets: | 950 | case StripOffsets: |
951 | tiff->stripoffsets = (unsigned*) xps_alloc(ctx, count * sizeof(unsigned)); | 951 | tiff->stripoffsets = (unsigned*) xps_alloc(ctx, count * sizeof(unsigned)); |
952 | if (!tiff->stripoffsets) | 952 | if (!tiff->stripoffsets) |
953 | return gs_throw(-1, "could not allocate strip offsets"); | 953 | return gs_throw(gs_error_VMerror, "could not allocate strip offsets"); |
954 | xps_read_tiff_tag_value(tiff->stripoffsets, tiff, type, value, count); | 954 | xps_read_tiff_tag_value(tiff->stripoffsets, tiff, type, value, count); |
955 | break; | 955 | break; |
956 | 956 | ||
957 | case StripByteCounts: | 957 | case StripByteCounts: |
958 | tiff->stripbytecounts = (unsigned*) xps_alloc(ctx, count * sizeof(unsigned)); | 958 | tiff->stripbytecounts = (unsigned*) xps_alloc(ctx, count * sizeof(unsigned)); |
959 | if (!tiff->stripbytecounts) | 959 | if (!tiff->stripbytecounts) |
960 | return gs_throw(-1, "could not allocate strip byte counts"); | 960 | return gs_throw(gs_error_VMerror, "could not allocate strip byte counts"); |
961 | xps_read_tiff_tag_value(tiff->stripbytecounts, tiff, type, value, count); | 961 | xps_read_tiff_tag_value(tiff->stripbytecounts, tiff, type, value, count); |
962 | break; | 962 | break; |
963 | 963 | ||
964 | case ColorMap: | 964 | case ColorMap: |
965 | tiff->colormap = (unsigned*) xps_alloc(ctx, count * sizeof(unsigned)); | 965 | tiff->colormap = (unsigned*) xps_alloc(ctx, count * sizeof(unsigned)); |
966 | if (!tiff->colormap) | 966 | if (!tiff->colormap) |
967 | return gs_throw(-1, "could not allocate color map"); | 967 | return gs_throw(gs_error_VMerror, "could not allocate color map"); |
968 | xps_read_tiff_tag_value(tiff->colormap, tiff, type, value, count); | 968 | xps_read_tiff_tag_value(tiff->colormap, tiff, type, value, count); |
969 | break; | 969 | break; |
970 | 970 | ||
diff --git a/xps/xpsxml.c b/xps/xpsxml.c index 02c3458ef..4f0add949 100644 --- a/xps/xpsxml.c +++ b/xps/xpsxml.c | |||
@@ -110,9 +110,10 @@ on_open_tag(void *zp, char *ns_name, char **atts) | |||
110 | } | 110 | } |
111 | 111 | ||
112 | item = xps_alloc(ctx, sizeof(xps_item_t) + attslen + namelen + textlen); | 112 | item = xps_alloc(ctx, sizeof(xps_item_t) + attslen + namelen + textlen); |
113 | if (!item) | 113 | if (!item) { |
114 | { | ||
115 | parser->error = "out of memory"; | 114 | parser->error = "out of memory"; |
115 | gs_throw(gs_error_VMerror, "out of memory.\n"); | ||
116 | return; | ||
116 | } | 117 | } |
117 | 118 | ||
118 | /* copy strings to new memory */ | 119 | /* copy strings to new memory */ |
@@ -198,6 +199,7 @@ on_text(void *zp, char *buf, int len) | |||
198 | if (!tmp) | 199 | if (!tmp) |
199 | { | 200 | { |
200 | parser->error = "out of memory"; | 201 | parser->error = "out of memory"; |
202 | gs_throw(gs_error_VMerror, "out of memory.\n"); | ||
201 | return; | 203 | return; |
202 | } | 204 | } |
203 | 205 | ||
@@ -249,12 +251,14 @@ xps_parse_xml(xps_context_t *ctx, byte *buf, int len) | |||
249 | XML_SetCharacterDataHandler(xp, (XML_CharacterDataHandler)on_text); | 251 | XML_SetCharacterDataHandler(xp, (XML_CharacterDataHandler)on_text); |
250 | 252 | ||
251 | code = XML_Parse(xp, (char*)buf, len, 1); | 253 | code = XML_Parse(xp, (char*)buf, len, 1); |
252 | if (code == 0) | 254 | if (code == 0 || parser.error != NULL) |
253 | { | 255 | { |
254 | if (parser.root) | 256 | if (parser.root) |
255 | xps_free_item(ctx, parser.root); | 257 | xps_free_item(ctx, parser.root); |
258 | if (XML_ErrorString(XML_GetErrorCode(xp)) != 0) | ||
259 | emprintf1(parser.ctx->memory, "XML_Error: %s\n", XML_ErrorString(XML_GetErrorCode(xp))); | ||
256 | XML_ParserFree(xp); | 260 | XML_ParserFree(xp); |
257 | gs_throw1(-1, "xml error: %s", XML_ErrorString(XML_GetErrorCode(xp))); | 261 | gs_throw1(-1, "parser error: %s", parser.error); |
258 | return NULL; | 262 | return NULL; |
259 | } | 263 | } |
260 | 264 | ||
diff --git a/xps/xpszip.c b/xps/xpszip.c index 7c8c5b352..64a695388 100644 --- a/xps/xpszip.c +++ b/xps/xpszip.c | |||
@@ -48,7 +48,11 @@ static inline int getlong(FILE *file) | |||
48 | static void * | 48 | static void * |
49 | xps_zip_alloc_items(xps_context_t *ctx, int items, int size) | 49 | xps_zip_alloc_items(xps_context_t *ctx, int items, int size) |
50 | { | 50 | { |
51 | return xps_alloc(ctx, items * size); | 51 | void *item = xps_alloc(ctx, items * size); |
52 | if (!item) { | ||
53 | gs_throw(gs_error_VMerror, "out of memory: item.\n"); | ||
54 | return NULL; | ||
55 | } | ||
52 | } | 56 | } |
53 | 57 | ||
54 | static void | 58 | static void |
@@ -126,6 +130,9 @@ xps_read_zip_entry(xps_context_t *ctx, xps_entry_t *ent, unsigned char *outbuf) | |||
126 | else if (method == 8) | 130 | else if (method == 8) |
127 | { | 131 | { |
128 | inbuf = xps_alloc(ctx, ent->csize); | 132 | inbuf = xps_alloc(ctx, ent->csize); |
133 | if (!inbuf) { | ||
134 | return gs_throw(gs_error_VMerror, "out of memory.\n"); | ||
135 | } | ||
129 | 136 | ||
130 | fread(inbuf, 1, ent->csize, ctx->file); | 137 | fread(inbuf, 1, ent->csize, ctx->file); |
131 | 138 | ||
@@ -196,7 +203,7 @@ xps_read_zip_dir(xps_context_t *ctx, int start_offset) | |||
196 | ctx->zip_count = count; | 203 | ctx->zip_count = count; |
197 | ctx->zip_table = xps_alloc(ctx, sizeof(xps_entry_t) * count); | 204 | ctx->zip_table = xps_alloc(ctx, sizeof(xps_entry_t) * count); |
198 | if (!ctx->zip_table) | 205 | if (!ctx->zip_table) |
199 | return gs_throw(-1, "cannot allocate zip entry table"); | 206 | return gs_throw(gs_error_VMerror, "cannot allocate zip entry table"); |
200 | 207 | ||
201 | memset(ctx->zip_table, 0, sizeof(xps_entry_t) * count); | 208 | memset(ctx->zip_table, 0, sizeof(xps_entry_t) * count); |
202 | 209 | ||
@@ -227,7 +234,7 @@ xps_read_zip_dir(xps_context_t *ctx, int start_offset) | |||
227 | 234 | ||
228 | ctx->zip_table[i].name = xps_alloc(ctx, namesize + 1); | 235 | ctx->zip_table[i].name = xps_alloc(ctx, namesize + 1); |
229 | if (!ctx->zip_table[i].name) | 236 | if (!ctx->zip_table[i].name) |
230 | return gs_throw(-1, "cannot allocate zip entry name"); | 237 | return gs_throw(gs_error_VMerror, "cannot allocate zip entry name"); |
231 | 238 | ||
232 | fread(ctx->zip_table[i].name, 1, namesize, ctx->file); | 239 | fread(ctx->zip_table[i].name, 1, namesize, ctx->file); |
233 | ctx->zip_table[i].name[namesize] = 0; | 240 | ctx->zip_table[i].name[namesize] = 0; |