shithub: jbig2

Download patch

ref: f680c2d09d76172f7adee998608a8df0b8d2828c
parent: 609901fe1d5496caeae2289ee20d7be965e413b0
author: Shailesh Mistry <[email protected]>
date: Sun Nov 20 05:29:47 EST 2011

Fix 691958: check for an image before marking a page complete. Also update return code to handle errors correctly.

--- a/jbig2_page.c
+++ b/jbig2_page.c
@@ -195,11 +195,11 @@
 int
 jbig2_complete_page (Jbig2Ctx *ctx)
 {
+    int code = 0;
 
     /* check for unfinished segments */
     if (ctx->segment_index != ctx->n_segments) {
       Jbig2Segment *segment = ctx->segments[ctx->segment_index];
-      int code = 0;
       /* Some versions of Xerox Workcentre generate PDF files
          with the segment data length field of the last segment
          set to -1. Try to cope with this here. */
@@ -213,9 +213,14 @@
         ctx->segment_index++;
       }
     }
-    ctx->pages[ctx->current_page].state = JBIG2_PAGE_COMPLETE;
 
-    return 0;
+    /* ensure image exists before marking page as complete */
+    if (ctx->pages[ctx->current_page].image != NULL)
+    {
+        ctx->pages[ctx->current_page].state = JBIG2_PAGE_COMPLETE;
+    }
+
+    return code;
 }
 
 /**