shithub: jbig2

Download patch

ref: e392ac06cebf0e5e9ed04b7c1949e34de0eb84c0
parent: 2e42e1c26456fb205f88dd1985de649026970530
author: Sebastian Rasmussen <sebras@gmail.com>
date: Wed May 30 11:31:10 EDT 2018

jbig2dec: Return NULL upon error, avoid returning variable.

This makes it clearer what is being returned upon error.

--- a/jbig2.c
+++ b/jbig2.c
@@ -110,7 +110,7 @@
     result = (Jbig2Ctx *) jbig2_alloc(allocator, sizeof(Jbig2Ctx), 1);
     if (result == NULL) {
         error_callback(error_callback_data, "initial context allocation failed", JBIG2_SEVERITY_FATAL, -1);
-        return result;
+        return NULL;
     }
 
     result->allocator = allocator;
@@ -129,7 +129,7 @@
     if (result->segments == NULL) {
         error_callback(error_callback_data, "initial segments allocation failed", JBIG2_SEVERITY_FATAL, -1);
         jbig2_free(allocator, result);
-        return result;
+        return NULL;
     }
     result->segment_index = 0;
 
@@ -140,7 +140,7 @@
         error_callback(error_callback_data, "initial pages allocation failed", JBIG2_SEVERITY_FATAL, -1);
         jbig2_free(allocator, result->segments);
         jbig2_free(allocator, result);
-        return result;
+        return NULL;
     }
     {
         int index;
--- a/jbig2_arith.c
+++ b/jbig2_arith.c
@@ -162,7 +162,7 @@
     result = jbig2_new(ctx, Jbig2ArithState, 1);
     if (result == NULL) {
         jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "failed to allocate Jbig2ArithState in jbig2_arith_new");
-        return result;
+        return NULL;
     }
 
     result->ws = ws;
--- a/jbig2_arith_iaid.c
+++ b/jbig2_arith_iaid.c
@@ -49,7 +49,7 @@
 
     if (result == NULL) {
         jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "failed to allocate storage in jbig2_arith_iaid_ctx_new");
-        return result;
+        return NULL;
     }
 
     result->SBSYMCODELEN = SBSYMCODELEN;
--- a/jbig2_arith_int.c
+++ b/jbig2_arith_int.c
@@ -43,6 +43,7 @@
 
     if (result == NULL) {
         jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "failed to allocate Jbig2ArithIntCtx in jbig2_arith_int_ctx_new");
+        return NULL;
     } else {
         memset(result->IAx, 0, sizeof(result->IAx));
     }
--- a/jbig2_huffman.c
+++ b/jbig2_huffman.c
@@ -92,6 +92,7 @@
         }
     } else {
         jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "failed to allocate new huffman coding state");
+        return NULL;
     }
 
     return result;
--- a/jbig2_segment.c
+++ b/jbig2_segment.c
@@ -59,7 +59,7 @@
     result = jbig2_new(ctx, Jbig2Segment, 1);
     if (result == NULL) {
         jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "failed to allocate segment in jbig2_parse_segment_header");
-        return result;
+        return NULL;
     }
 
     /* 7.2.2 */