about summary refs log tree commit diff
path: root/analyzer/pgmtexture.c
diff options
context:
space:
mode:
Diffstat (limited to 'analyzer/pgmtexture.c')
-rw-r--r--analyzer/pgmtexture.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/analyzer/pgmtexture.c b/analyzer/pgmtexture.c
index 5af51bf5..06db12f2 100644
--- a/analyzer/pgmtexture.c
+++ b/analyzer/pgmtexture.c
@@ -915,6 +915,8 @@ main (int argc, const char ** argv) {
 
     pm_proginit(&argc, argv);
 
+    d = 1;
+
     argn = 1;
 
     /* Check for flags. */
@@ -942,11 +944,13 @@ main (int argc, const char ** argv) {
     if ( argn != argc )
         pm_usage( usage );
 
-    d = 1;
-
     grays = pgm_readpgm(ifP, &cols, &rows, &maxval);
     pm_close (ifP);
 
+    if (maxval > PGM_MAXMAXVAL)
+        pm_error("Maxval %u is too high.  We can handle only up to %u",
+                 maxval, PGM_MAXMAXVAL);
+
     /* Determine the number of different gray scales (not maxval) */
     for (i = 0; i <= PGM_MAXMAXVAL; ++i)
         tone[i] = -1;