shithub: jbig2

Download patch

ref: f125f9553a1e3c8088cf59df7c983aef3785641a
parent: c744e7207254f6719eb011a3a0b4984fdfa369dd
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Fri May 16 19:58:59 EDT 2008

Only check for a code length antecedent under RUNCODE32. RUNCODE33 and 
RUNCODE34 specify a repeat of zero so a previous code length isn't 
necessary.

Thanks to Justin Greer for catching this. Ghostscript bug 689835.


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

--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -141,14 +141,14 @@
 	    len = code;
 	    range = 1;
 	  } else {
-	    if (index < 1) {
-	      jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
-		"error decoding symbol id table: run length with no antecedent!");
-	      /* todo: memory cleanup */
-	      return -1;
-	    }
 	    if (code == 32) {
 	      len = symcodelengths[index-1].PREFLEN;
+	      if (index < 1) {
+		jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
+	 	  "error decoding symbol id table: run length with no antecedent!");
+	        /* todo: memory cleanup */
+	        return -1;
+	      }
 	    } else {
 	      len = 0; /* code == 33 or 34 */
 	    }