shithub: jbig2

Download patch

ref: 20ebea4cc1337c84fb2a8761c4cb8fca72e5d143
parent: a97827f45c90f51502fc0ca9290787b4b660a0ee
author: Sebastian Rasmussen <sebras@gmail.com>
date: Wed May 23 23:26:43 EDT 2018

jbig2dec: Pages without decoded images cannot be completed.

--- a/jbig2_page.c
+++ b/jbig2_page.c
@@ -188,7 +188,7 @@
 int
 jbig2_complete_page(Jbig2Ctx *ctx)
 {
-    int code = 0;
+    int code;
 
     /* check for unfinished segments */
     if (ctx->segment_index != ctx->n_segments) {
@@ -207,11 +207,12 @@
     }
 
     /* ensure image exists before marking page as complete */
-    if (!code && ctx->pages[ctx->current_page].image != NULL) {
-        ctx->pages[ctx->current_page].state = JBIG2_PAGE_COMPLETE;
+    if (ctx->pages[ctx->current_page].image == NULL) {
+        return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "page has no image, cannot be completed");
     }
 
-    return code;
+    ctx->pages[ctx->current_page].state = JBIG2_PAGE_COMPLETE;
+    return 0;
 }
 
 /**