rev 277 - trunk
[email protected] Wed, 1 Oct 2003 10:36:27 -0700 (PDT)
| Newsgroups | gmane.comp.printing.ghostscript.jbig2dec.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: giles
Date: 2003-10-01 10:05:28 -0700 (Wed, 01 Oct 2003)
New Revision: 277
Modified:
trunk/jbig2_text.c
Log:
Add protection against uninitialized dictionary lists, as can happen for
example when parsing a huffman-coded dictionary (nyi).
Modified: trunk/jbig2_text.c
===================================================================
--- trunk/jbig2_text.c 2003-10-01 14:21:19 UTC (rev 276)
+++ trunk/jbig2_text.c 2003-10-01 17:05:28 UTC (rev 277)
@@ -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);