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_hash.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_hash.c')
-rw-r--r-- | fitz/base_hash.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fitz/base_hash.c b/fitz/base_hash.c index d6ff8ca0..79943a1d 100644 --- a/fitz/base_hash.c +++ b/fitz/base_hash.c @@ -54,8 +54,16 @@ fz_new_hash_table(fz_context *ctx, int initialsize, int keylen) table->keylen = keylen; table->size = initialsize; table->load = 0; - table->ents = fz_malloc_array(ctx, table->size, sizeof(fz_hash_entry)); - memset(table->ents, 0, sizeof(fz_hash_entry) * table->size); + fz_try(ctx) + { + table->ents = fz_malloc_array(ctx, table->size, sizeof(fz_hash_entry)); + memset(table->ents, 0, sizeof(fz_hash_entry) * table->size); + } + fz_catch(ctx) + { + fz_free(ctx, table); + fz_rethrow(ctx); + } return table; } |