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 /draw/draw_glyph.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 'draw/draw_glyph.c')
-rw-r--r-- | draw/draw_glyph.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/draw/draw_glyph.c b/draw/draw_glyph.c index 6cb1518a..30f18a5f 100644 --- a/draw/draw_glyph.c +++ b/draw/draw_glyph.c @@ -27,7 +27,15 @@ fz_new_glyph_cache(fz_context *ctx) fz_glyph_cache *cache; cache = fz_malloc(ctx, sizeof(fz_glyph_cache)); - cache->hash = fz_new_hash_table(ctx, 509, sizeof(fz_glyph_key)); + fz_try(ctx) + { + cache->hash = fz_new_hash_table(ctx, 509, sizeof(fz_glyph_key)); + } + fz_catch(ctx) + { + fz_free(ctx, cache); + fz_rethrow(ctx); + } cache->total = 0; return cache; @@ -58,6 +66,9 @@ fz_evict_glyph_cache(fz_context *ctx, fz_glyph_cache *cache) void fz_free_glyph_cache(fz_context *ctx, fz_glyph_cache *cache) { + if (!cache) + return; + fz_evict_glyph_cache(ctx, cache); fz_free_hash(cache->hash); fz_free(ctx, cache); |