shithub: jbig2

Download patch

ref: 6ceadfae4d6d6f36d7912b5d4a88f8be93996950
parent: 91f3a6acca0cd2a670911899d9058b862d07b527
author: Sebastian Rasmussen <[email protected]>
date: Sun Jun 10 12:36:21 EDT 2018

jbig2dec: Plug context leak upon errors.

E.g. failing to complete a page previously caused a context leak.

--- a/jbig2dec.c
+++ b/jbig2dec.c
@@ -373,7 +373,7 @@
 main(int argc, char **argv)
 {
     FILE *f = NULL, *f_page = NULL;
-    Jbig2Ctx *ctx;
+    Jbig2Ctx *ctx = NULL;
     uint8_t buf[4096];
     jbig2dec_params_t params;
     int filearg;
@@ -534,7 +534,6 @@
                 write_document_hash(&params);
         }
 
-        jbig2_ctx_free(ctx);
 
     }                           /* end params.mode switch */
 
@@ -542,6 +541,7 @@
     result = 0;
 
 cleanup:
+    jbig2_ctx_free(ctx);
     if (params.output_filename)
         free(params.output_filename);
     if (params.hash)