ref: ea866acb21033fd3cfe345352852ea1202ce2e32
parent: ca94f2ac3ab6cdbb6a36a72cae385afb4f25d4e8
author: Henry Stiles <henry.stiles@artifex.com>
date: Wed Aug 11 12:17:45 EDT 2010
Fix bug # 691532. Do not attempt to clone an image that does not exist, each completed page should have an associated image. We'd like to handle this corrupt file with a better fix, for example the absence of an end page segement is clearly a problem with respect to the specification, but Adobe and Artifex have chosen to support other "off spec" streams so more subtle and less obvious error checking is needed. Thanks to Tim Waugh for analysis on this problem. git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@11622 a1074d23-0009-0410-80fe-cf8c14f379e6
--- a/jbig2_page.c
+++ b/jbig2_page.c
@@ -291,10 +291,19 @@
/* search for a completed page */
for (index=0; index < ctx->max_page_index; index++) {
if (ctx->pages[index].state == JBIG2_PAGE_COMPLETE) {
+ Jbig2Image *img = ctx->pages[index].image;
+ uint32_t page_number = ctx->pages[index].number;
ctx->pages[index].state = JBIG2_PAGE_RETURNED;
- jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1,
- "page %d returned to the client", ctx->pages[index].number);
- return jbig2_image_clone(ctx, ctx->pages[index].image);
+ if (img != NULL) {
+ jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1,
+ "page %d returned to the client", page_number);
+ return jbig2_image_clone(ctx, img);
+ } else {
+ jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1,
+ "page %d returned with no associated image",
+ page_number);
+ ; /* continue */
+ }
}
}