From f7a0321c03fde85aab74a09b5770277915a7f274 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Mon, 12 Jun 2017 08:22:39 +0800 Subject: Drop type 3 glyph pixmap in case of error. --- source/fitz/font.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/fitz') diff --git a/source/fitz/font.c b/source/fitz/font.c index 67f87828..77041dd8 100644 --- a/source/fitz/font.c +++ b/source/fitz/font.c @@ -1258,7 +1258,7 @@ fz_render_t3_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matr fz_display_list *list; fz_rect bounds; fz_irect bbox; - fz_device *dev; + fz_device *dev = NULL; fz_pixmap *glyph; fz_pixmap *result; @@ -1292,11 +1292,12 @@ fz_render_t3_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matr /* Glyphs must always have alpha */ glyph = fz_new_pixmap_with_bbox(ctx, model, &bbox, 1); - fz_clear_pixmap(ctx, glyph); - dev = fz_new_draw_device_type3(ctx, NULL, glyph); + fz_var(dev); fz_try(ctx) { + fz_clear_pixmap(ctx, glyph); + dev = fz_new_draw_device_type3(ctx, NULL, glyph); fz_run_t3_glyph(ctx, font, gid, trm, dev); fz_close_device(ctx, dev); } @@ -1306,6 +1307,7 @@ fz_render_t3_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matr } fz_catch(ctx) { + fz_drop_pixmap(ctx, glyph); fz_rethrow(ctx); } -- cgit v1.2.3