summaryrefslogtreecommitdiff
path: root/gs/jbig2dec/jbig2_huffman.c
diff options
context:
space:
mode:
Diffstat (limited to 'gs/jbig2dec/jbig2_huffman.c')
-rw-r--r--gs/jbig2dec/jbig2_huffman.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gs/jbig2dec/jbig2_huffman.c b/gs/jbig2dec/jbig2_huffman.c
index b7420d1a7..ebeef5a3d 100644
--- a/gs/jbig2dec/jbig2_huffman.c
+++ b/gs/jbig2dec/jbig2_huffman.c
@@ -253,6 +253,12 @@ jbig2_huffman_get (Jbig2HuffmanState *hs,
entry = &table->entries[this_word >> (32 - log_table_size)];
flags = entry->flags;
PREFLEN = entry->PREFLEN;
+ if ((flags == (byte)-1) && (PREFLEN == (int)-1) && (entry->u.RANGELOW == -1))
+ {
+ if (oob)
+ *oob = -1;
+ return -1;
+ }
next_word = hs->next_word;
offset_bits += PREFLEN;
@@ -386,6 +392,8 @@ jbig2_build_huffman_table (Jbig2Ctx *ctx, const Jbig2HuffmanParams *params)
"couldn't allocate entries storage in jbig2_build_huffman_table");
return NULL;
}
+ /* fill now to catch missing JBIG2Globals later */
+ memset(entries, 0xFF, sizeof(Jbig2HuffmanEntry)*max_j);
result->entries = entries;
LENCOUNT[0] = 0;