shithub: jbig2

Download patch

ref: 3952f712a94604f51d0dff207dec16ed18dba2d3
parent: 7d17f7bb861b45319140572c786a20c4e044756a
author: Sebastian Rasmussen <[email protected]>
date: Sun May 14 08:36:28 EDT 2017

Fix memory leak in case of error.

--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -342,6 +342,7 @@
                 }
 
                 if ((code1 < 0) || (code2 < 0) || (code3 < 0) || (code4 < 0) || (code5 < 0)) {
+                    jbig2_image_release(ctx, IB);
                     code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "failed to decode data");
                     goto cleanup2;
                 }
@@ -368,11 +369,12 @@
                 code = jbig2_decode_refinement_region(ctx, segment, &rparams, as, refimage, GR_stats);
                 if (code < 0) {
                     jbig2_image_release(ctx, refimage);
+                    jbig2_image_release(ctx, IBO);
                     goto cleanup2;
                 }
-                IB = refimage;
 
                 jbig2_image_release(ctx, IBO);
+                IB = refimage;
 
                 /* 6.4.11 (7) */
                 if (params->SBHUFF) {