shithub: jbig2

Download patch

ref: 0577ac1d30bd76622e9c2cd36ff573b3e144b19c
parent: 0aa9e029d3d78790d747b8fd6c62f2f6ffe403f5
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Wed Dec 8 15:49:19 EST 2004

Error if the symbol id indicated for refinement in a refagg symbol 
dictionary segment is out of range. UBC test stream 042_13 triggers
this, we don't fix this here, only handle the error more verbosely.


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

--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -387,6 +387,10 @@
 		          code = jbig2_arith_int_decode(IARDY, as, &RDY);
 		      }
 
+		      if (ID >= ninsyms+NSYMSDECODED)
+			return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
+			  "refinement references unknown symbol %d", ID);
+   
 		      jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
 			"symbol is a refinement of id %d with the refinement applied at (%d,%d)",
 			ID, RDX, RDY);
@@ -395,7 +399,7 @@
 
 		      /* Table 18 */
 		      rparams.GRTEMPLATE = params->SDRTEMPLATE;
-		      rparams.reference = (ninsyms > ID) ? 
+		      rparams.reference = (ninsyms >= ID) ? 
 					params->SDINSYMS->glyphs[ID] :
 					SDNEWSYMS->glyphs[ID-ninsyms];
 		      rparams.DX = RDX;