shithub: jbig2

Download patch

ref: 20f6de3d3f3e09060dd20544ebb6d889226c32ba
parent: c2c5bd5716340b14d52c8f6b99631396028e51d5
author: Sebastian Rasmussen <sebras@gmail.com>
date: Wed May 23 20:33:18 EDT 2018

jbig2dec: Releasing a page cannot not fail.

It can only fail if you supply a random page pointer.
Don't do that it would be a programming error.

--- a/jbig2.h
+++ b/jbig2.h
@@ -91,7 +91,7 @@
 /* get the next available decoded page image. NULL means there isn't one. */
 Jbig2Image *jbig2_page_out(Jbig2Ctx *ctx);
 /* mark a returned page image as no longer needed. */
-int jbig2_release_page(Jbig2Ctx *ctx, Jbig2Image *image);
+void jbig2_release_page(Jbig2Ctx *ctx, Jbig2Image *image);
 /* mark the current page as complete, simulating an end-of-page segment (for broken streams) */
 int jbig2_complete_page(Jbig2Ctx *ctx);
 
--- a/jbig2_page.c
+++ b/jbig2_page.c
@@ -324,7 +324,7 @@
 /**
  * jbig2_release_page: tell the library a page can be freed
  **/
-int
+void
 jbig2_release_page(Jbig2Ctx *ctx, Jbig2Image *image)
 {
     int index;
@@ -335,11 +335,10 @@
             jbig2_image_release(ctx, image);
             ctx->pages[index].state = JBIG2_PAGE_RELEASED;
             jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1, "page %d released by the client", ctx->pages[index].number);
-            return 0;
+            return;
         }
     }
 
     /* no matching pages */
-    jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "jbig2_release_page called on unknown page");
-    return 1;
+    jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "jbig2_release_page called on unknown page");
 }