shithub: jbig2

Download patch

ref: 1f773152929142b68d41d97950fa54c355a3e2dc
parent: eedf4c69de311948c88fc26ee71b9227498e9aa0
author: Sebastian Rasmussen <sebras@gmail.com>
date: Wed May 23 17:48:31 EDT 2018

jbig2dec: Remember to free IAID context upon error.

Previously this might result in a memory leak.

--- a/jbig2_arith_iaid.c
+++ b/jbig2_arith_iaid.c
@@ -54,12 +54,14 @@
 
     result->SBSYMCODELEN = SBSYMCODELEN;
     result->IAIDx = jbig2_new(ctx, Jbig2ArithCx, ctx_size);
-    if (result->IAIDx != NULL) {
-        memset(result->IAIDx, 0, ctx_size);
-    } else {
+    if (result->IAIDx == NULL)
+    {
+        jbig2_free(ctx->allocator, result);
         jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "failed to allocate symbol ID storage in jbig2_arith_iaid_ctx_new");
+        return NULL;
     }
 
+    memset(result->IAIDx, 0, ctx_size);
     return result;
 }