From e6118ac1b13cc49f637861fccbc32a10c4ea1ea7 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 15 Dec 2011 19:49:16 +0000 Subject: Various Memsqueezing fixes. Fixes for leaks (and SEGVs, division by zeros etc) seen when Memsqueezing. --- fitz/base_hash.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'fitz/base_hash.c') 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; } -- cgit v1.2.3