diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-12-15 19:49:16 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2011-12-15 19:49:16 +0000 |
commit | e6118ac1b13cc49f637861fccbc32a10c4ea1ea7 (patch) | |
tree | 4ccb1fb5adf96d7794872502ee975825f250054a /fitz/base_object.c | |
parent | 3031a2480fe775df825de6674495d01ae2607d93 (diff) | |
download | mupdf-e6118ac1b13cc49f637861fccbc32a10c4ea1ea7.tar.xz |
Various Memsqueezing fixes.
Fixes for leaks (and SEGVs, division by zeros etc) seen when
Memsqueezing.
Diffstat (limited to 'fitz/base_object.c')
-rw-r--r-- | fitz/base_object.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/fitz/base_object.c b/fitz/base_object.c index 957396ea..ced40414 100644 --- a/fitz/base_object.c +++ b/fitz/base_object.c @@ -389,7 +389,15 @@ fz_new_array(fz_context *ctx, int initialcap) obj->u.a.len = 0; obj->u.a.cap = initialcap > 1 ? initialcap : 6; - obj->u.a.items = fz_malloc_array(ctx, obj->u.a.cap, sizeof(fz_obj*)); + fz_try(ctx) + { + obj->u.a.items = fz_malloc_array(ctx, obj->u.a.cap, sizeof(fz_obj*)); + } + fz_catch(ctx) + { + fz_free(ctx, obj); + fz_rethrow(ctx); + } for (i = 0; i < obj->u.a.cap; i++) obj->u.a.items[i] = NULL; @@ -537,7 +545,15 @@ fz_new_dict(fz_context *ctx, int initialcap) obj->u.d.len = 0; obj->u.d.cap = initialcap > 1 ? initialcap : 10; - obj->u.d.items = fz_malloc_array(ctx, obj->u.d.cap, sizeof(struct keyval)); + fz_try(ctx) + { + obj->u.d.items = fz_malloc_array(ctx, obj->u.d.cap, sizeof(struct keyval)); + } + fz_catch(ctx) + { + fz_free(ctx, obj); + fz_rethrow(ctx); + } for (i = 0; i < obj->u.d.cap; i++) { obj->u.d.items[i].k = NULL; |