about summary refs log tree commit diff
path: root/editor/pnmcat.c
diff options
context:
space:
mode:
Diffstat (limited to 'editor/pnmcat.c')
-rw-r--r--editor/pnmcat.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/editor/pnmcat.c b/editor/pnmcat.c
index 20dbf34d..cc86520f 100644
--- a/editor/pnmcat.c
+++ b/editor/pnmcat.c
@@ -155,7 +155,7 @@ computeOutputParms(unsigned int     const nfiles,
                    xelval *         const newmaxvalP,
                    int *            const newformatP) {
 
-    int newcols, newrows;
+    double newcols, newrows;
     int newformat;
     xelval newmaxval;
 
@@ -187,8 +187,18 @@ computeOutputParms(unsigned int     const nfiles,
             break;
 	    }
 	}
-    *newrowsP   = newrows;
-    *newcolsP   = newcols;
+
+    /* Note that while 'double' is not in general a precise numerical type,
+       in the case of a sum of integers which is less than INT_MAX, it
+       is exact, because double's precision is greater than int's.
+    */
+    if (newcols > INT_MAX)
+       pm_error("Output width too large: %.0f.", newcols);
+    if (newrows > INT_MAX)
+       pm_error("Output height too large: %.0f.", newrows);
+	
+    *newrowsP   = (int) newrows;
+    *newcolsP   = (int) newcols;
     *newmaxvalP = newmaxval;
     *newformatP = newformat;
 }