shithub: jbig2

Download patch

ref: 8055e400b7d9b32c355e8c7dc2cf286a59dc1ece
parent: 2d6d6e0c7b2c97e52a3363eae09841a17fe8e272
author: raph <raph@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Tue Jun 4 20:03:49 EDT 2002

Fixes bug in arithmetic integer decoding procedure. Thanks to William
Rucklidge for providing trace data to help track down the problem.


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

--- a/jbig2_arith_int.c
+++ b/jbig2_arith_int.c
@@ -48,20 +48,32 @@
 	{
 	  bit = jbig2_arith_decode(as, &IAx[PREV]);
 	  PREV = (PREV << 1) | bit;
+
 	  if (bit)
 	    {
 	      bit = jbig2_arith_decode(as, &IAx[PREV]);
 	      PREV = (PREV << 1) | bit;
-	      
+
 	      if (bit)
 		{
-		  n_tail = 32;
-		  offset = 4436;
+		  bit = jbig2_arith_decode(as, &IAx[PREV]);
+		  PREV = (PREV << 1) | bit;
+
+		  if (bit)
+		    {
+		      n_tail = 32;
+		      offset = 4436;
+		    }
+		  else
+		    {
+		      n_tail = 12;
+		      offset = 340;
+		    }
 		}
 	      else
 		{
-		  n_tail = 12;
-		  offset = 340;
+		  n_tail = 8;
+		  offset = 84;
 		}
 	    }
 	  else