shithub: jbig2

Download patch

ref: 6a99885954277048b0d73840941dc47ede4c103a
parent: 8acccc58c83123286b0954053a7dd899de5a0630
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Wed Aug 31 12:41:42 EDT 2005

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.



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

--- a/jbig2.c
+++ b/jbig2.c
@@ -400,6 +400,8 @@
   if (offset + 4 < z->size)
     result = (data[offset] << 24) | (data[offset + 1] << 16) |
       (data[offset + 2] << 8) | data[offset + 3];
+  else if (offset >= z->size)
+    return 0;
   else
     {
       int i;