shithub: jbig2

Download patch

ref: b3d5fd5a743c85e446adc78f6d6922fdba967467
parent: 9ec2217b0b1843a27db1bd4996951edeaba1ff93
author: Sebastian Rasmussen <[email protected]>
date: Wed May 23 21:24:32 EDT 2018

jbig2dec: Convert debug messages in debug code to warnings.

This is because the debug code calls functions that write
PBM images or similar, these may fail and when this happens
the calling function ought to print a warning and fail itself.

--- a/jbig2_page.c
+++ b/jbig2_page.c
@@ -238,9 +238,8 @@
 
 #ifdef OUTPUT_PBM
     code = jbig2_image_write_pbm(ctx->pages[ctx->current_page].image, stdout);
-    if (code < 0) {
-        jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, "failed to write page image");
-    }
+    if (code < 0)
+        return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to write page image");
 #endif
 
     return 0;
--- a/jbig2_refinement.c
+++ b/jbig2_refinement.c
@@ -141,11 +141,11 @@
         snprintf(name, 32, "refin-%d.pbm", count);
         code = jbig2_image_write_pbm_file(ref, name);
         if (code < 0)
-            jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1, "failed to write refinement input");
+            return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to write refinement input");
         snprintf(name, 32, "refout-%d.pbm", count);
         code = jbig2_image_write_pbm_file(image, name);
         if (code < 0)
-            jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1, "failed to write refinement output");
+            return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to write refinement output");
         count++;
     }
 #endif
--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -604,11 +604,12 @@
                     snprintf(name, 64, "sd.%04d.%04d.pbm", segment->number, NSYMSDECODED);
                     out = fopen(name, "wb");
                     code = jbig2_image_write_pbm(SDNEWSYMS->glyphs[NSYMSDECODED], out);
-                    if (code < 0)
-                        jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, "failed to write glyph");
-                    else
-                        jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, "writing out glyph as '%s' ...", name);
                     fclose(out);
+                    if (code < 0) {
+                        jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to write glyph");
+                        goto cleanup4;
+                    }
+                    jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, "writing out glyph as '%s' ...", name);
                 }
 #endif