shithub: jbig2

Download patch

ref: f96255c8451e2d07406e2bd5f513f1d0aec34f29
parent: 1fde432da43cbe5bc34f3a95ee5d2f2466090e52
author: Ralph Giles <giles@ghostscript.com>
date: Wed Jul 15 18:11:21 EDT 2009

Check the return code from jbig2_data_in().

This avoids printing multiple 'Not a JBIG2 file header' errors on
corrupt or invalid files.

--- a/jbig2dec.c
+++ b/jbig2dec.c
@@ -445,7 +445,8 @@
       int n_bytes = fread(buf, 1, sizeof(buf), f);
       if (n_bytes <= 0)
 	break;
-      jbig2_data_in(ctx, buf, n_bytes);
+      if (jbig2_data_in(ctx, buf, n_bytes))
+	break;
     }
   fclose(f);
 
@@ -460,7 +461,8 @@
 	  int n_bytes = fread(buf, 1, sizeof(buf), f_page);
 	  if (n_bytes <= 0)
 	    break;
-	  jbig2_data_in(ctx, buf, n_bytes);
+	  if (jbig2_data_in(ctx, buf, n_bytes))
+	    break;
 	}
       fclose(f_page);
       jbig2_global_ctx_free(global_ctx);