about summary refs log tree commit diff
path: root/converter/other/tifftopnm.c
diff options
context:
space:
mode:
Diffstat (limited to 'converter/other/tifftopnm.c')
-rw-r--r--converter/other/tifftopnm.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/converter/other/tifftopnm.c b/converter/other/tifftopnm.c
index 0c301a4a..0fbbaad0 100644
--- a/converter/other/tifftopnm.c
+++ b/converter/other/tifftopnm.c
@@ -105,8 +105,8 @@ parseCommandLine(int argc, const char ** const argv,
    sometimes, one of these strings is actually just a suffix of an entry
    in argv!
 -----------------------------------------------------------------------------*/
+    optEntry * option_def;
     optStruct3 opt;
-    optEntry *option_def;
     unsigned int option_def_index;
     unsigned int alphaSpec;
 
@@ -130,7 +130,7 @@ parseCommandLine(int argc, const char ** const argv,
     OPTENT3(0,   "alphaout",
             OPT_STRING, &cmdlineP->alphaFilename, &alphaSpec,  0);
 
-    pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
+    pm_optParseOptions4(&argc, argv, opt, sizeof(opt), 0);
 
     if (argc - 1 == 0)
         cmdlineP->inputFilename = strdup("-");  /* he wants stdin */
@@ -714,23 +714,6 @@ analyzeImageType(TIFF *             const tiffP,
 
 
 
-static void
-reportOutputFormat(int const format) {
-
-    const char * formatDesc;
-
-    switch (format) {
-    case PBM_TYPE: formatDesc = "PBM"; break;
-    case PGM_TYPE: formatDesc = "PGM"; break;
-    case PPM_TYPE: formatDesc = "PPM"; break;
-    default: assert(false);
-    }
-
-    pm_message("writing %s file", formatDesc);
-}
-
-
-
 typedef struct {
     FILE *       imageoutFileP;
         /* The stream to which we write the PNM image.  Null for none. */
@@ -1372,6 +1355,9 @@ convertRasterByRows(pnmOut *       const pnmOutP,
     if (scanbuf == NULL)
         pm_error("can't allocate memory for scanline buffer");
 
+    if (UINT_MAX/cols < spp)
+        pm_error("Image is too wide/deep (%u x %u) for computations",
+                 cols, spp);
     MALLOCARRAY(samplebuf, cols * spp);
     if (samplebuf == NULL)
         pm_error("can't allocate memory for row buffer");
@@ -1684,7 +1670,7 @@ convertImage(TIFF *             const tifP,
     analyzeImageType(tifP, tiffDir.bps, tiffDir.spp, tiffDir.photomet,
                      &maxval, &format, colormap, cmdline.headerdump, cmdline);
 
-    reportOutputFormat(format);
+    pm_message("writing %s file", pnm_formattypenm(format));
 
     pnmOut_init(imageoutFileP, alphaFileP, tiffDir.width, tiffDir.height,
                 tiffDir.orientation, maxval, format, maxval,