about summary refs log tree commit diff
path: root/editor/pamstretch.c
diff options
context:
space:
mode:
Diffstat (limited to 'editor/pamstretch.c')
-rw-r--r--editor/pamstretch.c16
1 files changed, 13 insertions, 3 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);
     }