about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-10-07 20:25:14 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-10-07 20:25:14 +0000
commit6b343a0ee4b3816ee5672453d54e694bf8f80d2b (patch)
tree7af785e651c3ce85f7b0fcf45e9f13f84c96e1ec
parent1e71a99f263ddc9080b42b2fd1bd9dd01989c5a5 (diff)
downloadnetpbm-mirror-6b343a0ee4b3816ee5672453d54e694bf8f80d2b.tar.gz
netpbm-mirror-6b343a0ee4b3816ee5672453d54e694bf8f80d2b.tar.xz
netpbm-mirror-6b343a0ee4b3816ee5672453d54e694bf8f80d2b.zip
fix arithmetic overflow
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4733 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY3
-rw-r--r--editor/pnmscalefixed.c2
2 files changed, 4 insertions, 1 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 4b9ce1a3..6813d6ab 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -17,6 +17,9 @@ not yet  BJH  Release 11.05.00
               ppmtoxpm: fix incorrect output with insanely large number of
               colors.
 
+              pnmscalefixed: fix incorrect output with really big image and
+              -pixels option.
+
               Build: Fix compile error on systems without 'asprintf'.
               Introduced in Netpbm 11.04 (September 2023).
 
diff --git a/editor/pnmscalefixed.c b/editor/pnmscalefixed.c
index 7d33a9c2..05d56578 100644
--- a/editor/pnmscalefixed.c
+++ b/editor/pnmscalefixed.c
@@ -215,7 +215,7 @@ compute_output_dimensions(const struct cmdline_info cmdline,
                           int * newrowsP, int * newcolsP) {
 
     if (cmdline.pixels) {
-        if (rows * cols <= cmdline.pixels) {
+        if (rows <= cmdline.pixels / cols) {
             *newrowsP = rows;
             *newcolsP = cols;
         } else {