summaryrefslogtreecommitdiff
path: root/fitz/base_hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'fitz/base_hash.c')
-rw-r--r--fitz/base_hash.c12
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;
}