about summary refs log tree commit diff
path: root/converter
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-05-31 19:46:50 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-05-31 19:46:50 +0000
commit9776c7d07f50000e6279fb733a9189f10828b0fa (patch)
tree3d088f81a923ed1fd278c20f8cc095e4c86d1cf9 /converter
parente6dda147e0a4d1edab6b64c25e19a11dcad6d0e5 (diff)
downloadnetpbm-mirror-9776c7d07f50000e6279fb733a9189f10828b0fa.tar.gz
netpbm-mirror-9776c7d07f50000e6279fb733a9189f10828b0fa.tar.xz
netpbm-mirror-9776c7d07f50000e6279fb733a9189f10828b0fa.zip
Handle input with no mode setting
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3825 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r--converter/ppm/pjtoppm.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/converter/ppm/pjtoppm.c b/converter/ppm/pjtoppm.c
index ffb01d0c..9d23d47b 100644
--- a/converter/ppm/pjtoppm.c
+++ b/converter/ppm/pjtoppm.c
@@ -10,6 +10,8 @@
 ** implied warranty.
 */
 
+#include <stdbool.h>
+
 #include "ppm.h"
 #include "pm_c_util.h"
 #include "mallocvar.h"
@@ -54,6 +56,7 @@ main(int argc, const char ** argv) {
     int *imlen;
     FILE * ifP;
     int mode;
+    bool modeIsSet;
     int argn;
     unsigned char bf[3];
     pixel * pixrow;
@@ -74,6 +77,7 @@ main(int argc, const char ** argv) {
 
     row = 0;  /* initial value */
     plane = 0;  /* initial value */
+    modeIsSet = false;  /* initial value */
 
     while ((c = fgetc(ifP)) != -1) {
         if (c != '\033')
@@ -145,6 +149,7 @@ main(int argc, const char ** argv) {
                     if (val != 0 && val != 1)
                         pm_error("unimplemented transmission mode %d", val);
                     mode = val;
+                    modeIsSet = true;
                     break;
                 case 'V':   /* send plane */
                 case 'W':   /* send last plane */
@@ -214,6 +219,10 @@ main(int argc, const char ** argv) {
         } /* switch */
     }
     pm_close(ifP);
+
+    if (!modeIsSet)
+        pm_error("Input does not contain a 'bM' transmission mode order");
+
     rows = row;
     if (mode == 1) {
         int const newcols = 10240;  /* It could not be larger that that! */