about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/HISTORY4
-rw-r--r--other/pamstack.c5
2 files changed, 9 insertions, 0 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index a2aa6f47..8bd31abb 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -20,6 +20,10 @@ not yet  BJH  Release 11.04.00
               pamstack: Fix -lcmmaxval: chooses wrong maxval.  Always
               broken (-lcmmaxval was new in Netpbm 11.03 (June 2023)).
 
+              pamstack: Fail gracefully when total number of planes is too
+              large for unsigned integer.  Always broken (Pamstack was new in
+              Netpbm 10.0 (June 2002).
+
 23.06.28 BJH  Release 11.03.00
 
               pamstack: Add -firstmaxval, -lcmmaxval
diff --git a/other/pamstack.c b/other/pamstack.c
index 285e02c0..533795ca 100644
--- a/other/pamstack.c
+++ b/other/pamstack.c
@@ -242,6 +242,11 @@ processOneImageInAllStreams(unsigned int       const nInput,
         maxvalLcm = pm_lcm(maxvalLcm + 1, inpam[inputSeq].maxval + 1, 1,
                            PAM_OVERALL_MAXVAL + 1) - 1;
 
+        if (inpam[inputSeq].depth > UINT_MAX - outputDepth)
+            pm_error("Total number of planes is too large to compute "
+                     "(at least %u plus %u)",
+                     outputDepth, inpam[inputSeq].depth);
+
         outputDepth += inpam[inputSeq].depth;
     }