shithub: jbig2

Download patch

ref: ad0de34366fd42c8f95d519dccb91115c4278580
parent: bff29a59cb009b2cb0b397c137e8576e9f3acb0b
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Tue Jan 4 00:17:39 EST 2005

Also correctly free the integer arith coding contexts in symbol 
dictionary decode.


git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@386 ded80894-8fb9-0310-811b-c03f3676ab4d

--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -243,9 +243,9 @@
 	  int SBSYMCODELEN;
 	  for (SBSYMCODELEN = 0; (1 << SBSYMCODELEN) < tmp; SBSYMCODELEN++);
 	  IAID = jbig2_arith_iaid_ctx_new(ctx, SBSYMCODELEN);
+	  IARDX = jbig2_arith_int_ctx_new(ctx);
+	  IARDY = jbig2_arith_int_ctx_new(ctx);
       }
-      IARDX = jbig2_arith_int_ctx_new(ctx);
-      IARDY = jbig2_arith_int_ctx_new(ctx);
   } else {
       jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
 	"NYI: huffman coded symbol dictionary");
@@ -487,6 +487,15 @@
   jbig2_sd_release(ctx, SDNEWSYMS);
   
   if (!params->SDHUFF) {
+    jbig2_arith_int_ctx_free(ctx, IADH);
+    jbig2_arith_int_ctx_free(ctx, IADW);
+    jbig2_arith_int_ctx_free(ctx, IAEX);
+    jbig2_arith_int_ctx_free(ctx, IAAI);
+    if (params->SDREFAGG) {
+      jbig2_arith_iaid_ctx_free(ctx, IAID);
+      jbig2_arith_int_ctx_free(ctx, IARDX);
+      jbig2_arith_int_ctx_free(ctx, IARDY);
+    }
     jbig2_free(ctx->allocator, as);  
     jbig2_word_stream_buf_free(ctx, ws);
   }