about summary refs log tree commit diff
path: root/converter/pbm/g3topbm.c
diff options
context:
space:
mode:
Diffstat (limited to 'converter/pbm/g3topbm.c')
-rw-r--r--converter/pbm/g3topbm.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/converter/pbm/g3topbm.c b/converter/pbm/g3topbm.c
index b0d08f9e..fcac1981 100644
--- a/converter/pbm/g3topbm.c
+++ b/converter/pbm/g3topbm.c
@@ -753,7 +753,6 @@ main(int argc, char * argv[]) {
     struct bitStream bitStream;
     unsigned int rows, cols;
     unsigned char ** packedBits;
-    int row;
 
     pbm_init(&argc, argv);
 
@@ -779,9 +778,13 @@ main(int argc, char * argv[]) {
 
     pm_close(ifP);
 
-    pbm_writepbminit(stdout, cols, rows, 0);
-    for (row = 0; row < rows; ++row)
-        pbm_writepbmrow_packed(stdout, packedBits[row], cols, 0);
+    if (cols > 0 && rows > 0) {
+        unsigned int row;
+        pbm_writepbminit(stdout, cols, rows, 0);
+        for (row = 0; row < rows; ++row)
+            pbm_writepbmrow_packed(stdout, packedBits[row], cols, 0);
+    } else
+        pm_error("No image data in input");
 
     pm_close(stdout);