rev 435 - trunk

[email protected] Mon, 5 Dec 2005 16:02:26 -0800 (PST)
Newsgroups gmane.comp.printing.ghostscript.jbig2dec.cvs
Message-ID <[email protected]>
Author: giles
Date: 2005-08-31 09:41:42 -0700 (Wed, 31 Aug 2005)
New Revision: 435

Modified:
   trunk/jbig2.c
Log:
Make a Jbig2WordStream return zeros past the end of the defined
buffer, as can happen when the huffman decoder tries to fill
its 'next_word' lookahead near the end of a segment.

Previously, we just relied on there being some data we could
read (and then ignore) which usually worked, but caused a
segfault with the 688080.pdf test file due to chance read
buffer alignment.



Modified: trunk/jbig2.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/jbig2.c	2005-08-30 02:05:05 UTC (rev 434)
+++ trunk/jbig2.c	2005-08-31 16:41:42 UTC (rev 435)
@@ -400,6 +400,8 @@
   if (offset + 4 < z->size)
     result =3D (data[offset] << 24) | (data[offset + 1] << 16) |
       (data[offset + 2] << 8) | data[offset + 3];
+  else if (offset >=3D z->size)
+    return 0;
   else
     {
       int i;