diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2016-10-29 15:00:50 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2016-12-14 18:44:40 +0100 |
commit | a8edb9b209d75b844165b041fc49e1db302d9c51 (patch) | |
tree | 9031cf7245087dcf6e2ea286d4b417c2e3679db8 /source/tools | |
parent | f2e8dfeb3d4ccdcdbdf8e2e122883b0ec7145bc6 (diff) | |
download | mupdf-a8edb9b209d75b844165b041fc49e1db302d9c51.tar.xz |
Plug pixmap leak when fz_convert_pixmap() throws.
Diffstat (limited to 'source/tools')
-rw-r--r-- | source/tools/pdfextract.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/source/tools/pdfextract.c b/source/tools/pdfextract.c index d65befdd..e8e03965 100644 --- a/source/tools/pdfextract.c +++ b/source/tools/pdfextract.c @@ -28,20 +28,20 @@ static int isfontdesc(pdf_obj *obj) return pdf_name_eq(ctx, type, PDF_NAME_FontDescriptor); } -static void writepixmap(fz_context *ctx, fz_pixmap *pix, char *file, int rgb) +static void writepixmap(fz_context *ctx, fz_pixmap *pix, char *file, int dorgb) { char buf[1024]; - fz_pixmap *converted = NULL; + fz_pixmap *rgb = NULL; if (!pix) return; - if (rgb && pix->colorspace && pix->colorspace != fz_device_rgb(ctx)) + if (dorgb && pix->colorspace && pix->colorspace != fz_device_rgb(ctx)) { fz_irect bbox; - converted = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), fz_pixmap_bbox(ctx, pix, &bbox), pix->alpha); - fz_convert_pixmap(ctx, converted, pix); - pix = converted; + rgb = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), fz_pixmap_bbox(ctx, pix, &bbox), pix->alpha); + fz_convert_pixmap(ctx, rgb, pix); + pix = rgb; } if (pix->n - pix->alpha <= 3) @@ -57,7 +57,7 @@ static void writepixmap(fz_context *ctx, fz_pixmap *pix, char *file, int rgb) fz_save_pixmap_as_pam(ctx, pix, buf); } - fz_drop_pixmap(ctx, converted); + fz_drop_pixmap(ctx, rgb); } static void |