From 605d8a1b2760845b772ce47c5d65a871281f58de Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Thu, 6 Sep 2018 04:07:54 +0800 Subject: Bug 699723: Free alternative colorspace upon error when loading ICC colorspace. --- source/pdf/pdf-colorspace.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/pdf/pdf-colorspace.c b/source/pdf/pdf-colorspace.c index d112baa7..49f2354b 100644 --- a/source/pdf/pdf-colorspace.c +++ b/source/pdf/pdf-colorspace.c @@ -71,14 +71,17 @@ load_icc_based(fz_context *ctx, pdf_obj *dict, int alt) fz_drop_buffer(ctx, buffer); fz_catch(ctx) { - if (!alt) + if (!alt) { + fz_drop_colorspace(ctx, cs_alt); fz_rethrow(ctx); + } } if (cs) { if (n != 1 && n != 3 && n != 4) { + fz_drop_colorspace(ctx, cs_alt); fz_drop_colorspace(ctx, cs); fz_throw(ctx, FZ_ERROR_GENERIC, "ICC Based must have 1, 3 or 4 components"); } @@ -94,7 +97,10 @@ load_icc_based(fz_context *ctx, pdf_obj *dict, int alt) * or because we aren't in an ICC workflow. If we aren't allowed * to return the alternate, then that's all she wrote. */ if (!alt) + { + fz_drop_colorspace(ctx, cs_alt); fz_throw(ctx, FZ_ERROR_GENERIC, "Unable to read ICC workflow"); + } /* If we have an alternate we are allowed to use, return that. */ if (cs_alt) -- cgit v1.2.3