summaryrefslogtreecommitdiff
path: root/pdf/pdf_colorspace.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-12-16 19:15:43 +0000
committerRobin Watts <robin.watts@artifex.com>2011-12-16 19:15:43 +0000
commit42cb763c9ce52e671c681a9321a5e1b5741c9caf (patch)
tree7956292ef432abe4ca1c9bc0e5653370f093321c /pdf/pdf_colorspace.c
parent40ba2101c5b3c49379dd6997ceccf9256a7efe69 (diff)
downloadmupdf-42cb763c9ce52e671c681a9321a5e1b5741c9caf.tar.xz
More MemSqueezing fixes.
Diffstat (limited to 'pdf/pdf_colorspace.c')
-rw-r--r--pdf/pdf_colorspace.c53
1 files changed, 37 insertions, 16 deletions
diff --git a/pdf/pdf_colorspace.c b/pdf/pdf_colorspace.c
index 0efcd13a..4ebf7826 100644
--- a/pdf/pdf_colorspace.c
+++ b/pdf/pdf_colorspace.c
@@ -94,15 +94,18 @@ static fz_colorspace *
load_separation(pdf_xref *xref, fz_obj *array)
{
fz_colorspace *cs;
- struct separation *sep;
+ struct separation *sep = NULL;
fz_context *ctx = xref->ctx;
fz_obj *nameobj = fz_array_get(array, 1);
fz_obj *baseobj = fz_array_get(array, 2);
fz_obj *tintobj = fz_array_get(array, 3);
fz_colorspace *base;
- pdf_function *tint;
+ pdf_function *tint = NULL;
int n;
+ fz_var(tint);
+ fz_var(sep);
+
if (fz_is_array(nameobj))
n = fz_array_len(nameobj);
else
@@ -114,19 +117,29 @@ load_separation(pdf_xref *xref, fz_obj *array)
base = pdf_load_colorspace(xref, baseobj);
/* RJW: "cannot load base colorspace (%d %d R)", fz_to_num(baseobj), fz_to_gen(baseobj) */
- tint = pdf_load_function(xref, tintobj);
- /* RJW: fz_drop_colorspace(ctx, base);
- * "cannot load tint function (%d %d R)", fz_to_num(tintobj), fz_to_gen(tintobj) */
-
- sep = fz_malloc_struct(ctx, struct separation);
- sep->base = base;
- sep->tint = tint;
-
- cs = fz_new_colorspace(ctx, n == 1 ? "Separation" : "DeviceN", n);
- cs->to_rgb = separation_to_rgb;
- cs->free_data = free_separation;
- cs->data = sep;
- cs->size += sizeof(struct separation) + (base ? base->size : 0) + pdf_function_size(tint);
+ fz_try(ctx)
+ {
+ tint = pdf_load_function(xref, tintobj);
+ /* RJW: fz_drop_colorspace(ctx, base);
+ * "cannot load tint function (%d %d R)", fz_to_num(tintobj), fz_to_gen(tintobj) */
+
+ sep = fz_malloc_struct(ctx, struct separation);
+ sep->base = base;
+ sep->tint = tint;
+
+ cs = fz_new_colorspace(ctx, n == 1 ? "Separation" : "DeviceN", n);
+ cs->to_rgb = separation_to_rgb;
+ cs->free_data = free_separation;
+ cs->data = sep;
+ cs->size += sizeof(struct separation) + (base ? base->size : 0) + pdf_function_size(tint);
+ }
+ fz_catch(ctx)
+ {
+ fz_drop_colorspace(ctx, base);
+ pdf_drop_function(ctx, tint);
+ fz_free(ctx, sep);
+ fz_rethrow(ctx);
+ }
return cs;
}
@@ -371,7 +384,15 @@ pdf_load_colorspace(pdf_xref *xref, fz_obj *obj)
cs = pdf_load_colorspace_imp(xref, obj);
/* RJW: "cannot load colorspace (%d %d R)", fz_to_num(obj), fz_to_gen(obj) */
- fz_store_item(ctx, obj, cs, cs->size);
+ fz_try(ctx)
+ {
+ fz_store_item(ctx, obj, cs, cs->size);
+ }
+ fz_catch(ctx)
+ {
+ fz_drop_colorspace(ctx, cs);
+ fz_rethrow(ctx);
+ }
return cs;
}