From 9776c7d07f50000e6279fb733a9189f10828b0fa Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 31 May 2020 19:46:50 +0000 Subject: Handle input with no mode setting git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3825 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/ppm/pjtoppm.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'converter') 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 + #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! */ -- cgit 1.4.1