about summary refs log tree commit diff
path: root/editor
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-02-10 07:37:59 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-02-10 07:37:59 +0000
commited784035a8c397995f66eac86c8072cb7546643b (patch)
tree4e6d50d91761e4fe4170c9dbe57ecd4a3f4c2a67 /editor
parent76758a935da3169d8fd556532f4180b109589561 (diff)
downloadnetpbm-mirror-ed784035a8c397995f66eac86c8072cb7546643b.tar.gz
netpbm-mirror-ed784035a8c397995f66eac86c8072cb7546643b.tar.xz
netpbm-mirror-ed784035a8c397995f66eac86c8072cb7546643b.zip
Release 10.73.25
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@3546 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor')
-rw-r--r--editor/pamstretch.c16
-rw-r--r--editor/ppmbrighten.c25
-rw-r--r--editor/ppmdraw.c2
3 files changed, 30 insertions, 13 deletions
diff --git a/editor/pamstretch.c b/editor/pamstretch.c
index 8980dd0b..04883c35 100644
--- a/editor/pamstretch.c
+++ b/editor/pamstretch.c
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <ctype.h>
+#include <limits.h>
 
 #include "pm_c_util.h"
 #include "pam.h"
@@ -389,9 +390,18 @@ main(int argc,char *argv[]) {
     }
     {
         unsigned int const dropped = cmdline.edge_mode == EDGE_DROP ? 1 : 0;
-
-        outpam.width = (inpam.width - dropped) * cmdline.xscale;
-        outpam.height = (inpam.height - dropped) * cmdline.yscale;
+        double const width  = (inpam.width  - dropped) * cmdline.xscale;
+        double const height = (inpam.height - dropped) * cmdline.yscale;
+
+        if (width > INT_MAX - 2)
+            pm_error("output image width (%f) too large for computations",
+                     width);
+        if (height > INT_MAX - 2)
+            pm_error("output image height (%f) too large for computation",
+                     height);
+ 
+        outpam.width  = width;
+        outpam.height = height;
 
         pnm_writepaminit(&outpam);
     }
diff --git a/editor/ppmbrighten.c b/editor/ppmbrighten.c
index a7aba2e7..a3e9a270 100644
--- a/editor/ppmbrighten.c
+++ b/editor/ppmbrighten.c
@@ -292,12 +292,17 @@ main(int argc, char * argv[]) {
         pm_tell2(ifP, &rasterPos, sizeof(rasterPos));
         getMinMax(ifP, cols, rows, maxval, format, &minValue, &maxValue);
         pm_seek2(ifP, &rasterPos, sizeof(rasterPos));
-        pm_message("Minimum value %u%% of full intensity "
-                   "being remapped to zero.",
-                   (minValue*100+MULTI/2)/MULTI);
-        pm_message("Maximum value %u%% of full intensity "
-                   "being remapped to full.",
-                   (maxValue*100+MULTI/2)/MULTI);
+        if (maxValue > minValue) {
+            pm_message("Minimum value %u%% of full intensity "
+                       "being remapped to zero.",
+                       (minValue*100+MULTI/2)/MULTI);
+            pm_message("Maximum value %u%% of full intensity "
+                       "being remapped to full.",
+                       (maxValue*100+MULTI/2)/MULTI);
+        } else
+            pm_message("Sole intensity value %u%% of full intensity "
+                       "not being remapped",
+                       (minValue*100+MULTI/2)/MULTI);
     }
 
     pixelrow = ppm_allocrow(cols);
@@ -313,9 +318,11 @@ main(int argc, char * argv[]) {
             RGBtoHSV(pixelrow[col], maxval, &H, &S, &V);
             
             if (cmdline.normalize) {
-                V -= minValue;
-                V = (V * MULTI) /
-                    (MULTI - (minValue+MULTI-maxValue));
+                if (maxValue > minValue) {
+                    V -= minValue;
+                    V = (V * MULTI) /
+                        (MULTI - (minValue+MULTI-maxValue));
+                }
             }
 
             S = MIN(MULTI, (unsigned int) (S * cmdline.saturation + 0.5));
diff --git a/editor/ppmdraw.c b/editor/ppmdraw.c
index 63d781ec..bd569e03 100644
--- a/editor/ppmdraw.c
+++ b/editor/ppmdraw.c
@@ -569,7 +569,7 @@ parseDrawCommand(struct tokenSet             const commandTokens,
                 const char * const typeArg = commandTokens.token[1];
                 if (streq(typeArg, "normal"))
                     drawCommandP->u.setlinetypeArg.type = PPMD_LINETYPE_NORMAL;
-                else if (streq(typeArg, "normal"))
+                else if (streq(typeArg, "nodiag"))
                     drawCommandP->u.setlinetypeArg.type = 
                         PPMD_LINETYPE_NODIAGS;
                 else