about summary refs log tree commit diff
path: root/lib/libpgm2.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libpgm2.c')
-rw-r--r--lib/libpgm2.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libpgm2.c b/lib/libpgm2.c
index 2e3aba90..ec3539a2 100644
--- a/lib/libpgm2.c
+++ b/lib/libpgm2.c
@@ -15,6 +15,7 @@
 
 #include "netpbm/pm_c_util.h"
 #include "netpbm/mallocvar.h"
+#include "libpgm.h"
 #include "pgm.h"
 
 
@@ -28,6 +29,13 @@ pgm_writepgminit(FILE * const fileP,
 
     bool const plainFormat = forceplain || pm_plain_output;
 
+    /* For Caller's convenience, we include validating computability of the
+       image parameters, since Caller may be using them in arithmetic after
+       our return.
+    */
+    pgm_validateComputableSize(cols, rows);
+    pgm_validateComputableMaxval(maxval);
+
     if (maxval > PGM_OVERALLMAXVAL && !plainFormat)
         pm_error("too-large maxval passed to ppm_writepgminit(): %d.\n"
                  "Maximum allowed by the PGM format is %d.",