about summary refs log tree commit diff
path: root/lib/libpamread.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libpamread.c')
-rw-r--r--lib/libpamread.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libpamread.c b/lib/libpamread.c
index f4d85493..0506d020 100644
--- a/lib/libpamread.c
+++ b/lib/libpamread.c
@@ -71,9 +71,14 @@ readPlainNonPbmRow(const struct pam * const pamP,
     for (col = 0; col < pamP->width; ++col) {
         unsigned int plane;
         for (plane = 0; plane < pamP->depth; ++plane)
-            if (tuplerow)
+            if (tuplerow) {
                 tuplerow[col][plane] = pm_getuint(pamP->file);
-            else
+
+                if (tuplerow[col][plane] > pamP->maxval)
+                    pm_error("Plane %u sample value %lu exceeds the "
+                             "image maxval of %lu",
+                             plane, tuplerow[col][plane], pamP->maxval);
+            } else
                 pm_getuint(pamP->file);  /* read data and discard */
     }
 }