ref: 539a19a063a962277c04f2c36dbdebc9bad28649
parent: 1fd3f35b2f031f1cad486daeff3f625588745e33
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Wed Oct 1 13:05:28 EDT 2003
Add protection against uninitialized dictionary lists, as can happen for example when parsing a huffman-coded dictionary (nyi). git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@277 ded80894-8fb9-0310-811b-c03f3676ab4d
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -116,7 +116,7 @@
int code;
max_id = 0;
- for (index = 0; index < n_dicts; index ++) {
+ for (index = 0; index < n_dicts; index++) {
max_id += dicts[index]->n_symbols;
}
jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
@@ -415,7 +415,25 @@
return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
"text region refers to no symbol dictionaries!");
}
-
+ if (dicts == NULL) {
+ return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
+ "unable to retrive symbol dictionaries!"
+ " previous parsing error?");
+ } else {
+ int index;
+ if (dicts[0] == NULL) {
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING,
+ segment->number,
+ "unable to find first referenced symbol dictionary!");
+ }
+ for (index = 1; index < n_dicts; index++)
+ if (dicts[index] == NULL) {
+ jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
+ "unable to find all referenced symbol dictionaries!");
+ n_dicts = index;
+ }
+ }
+
page_image = ctx->pages[ctx->current_page].image;
image = jbig2_image_new(ctx, region_info.width, region_info.height);