about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-12-19 18:58:40 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-12-19 18:58:40 +0000
commitfb38ea53371d1dab1bcc72411b058134db8d425c (patch)
tree890a4c6e549be1655e3db7c97f2141ada03034d2
parent066c3be5fbb16d51b067b8b99acd60400f29c077 (diff)
downloadnetpbm-mirror-fb38ea53371d1dab1bcc72411b058134db8d425c.tar.gz
netpbm-mirror-fb38ea53371d1dab1bcc72411b058134db8d425c.tar.xz
netpbm-mirror-fb38ea53371d1dab1bcc72411b058134db8d425c.zip
Check arguments for zero
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4813 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY2
-rw-r--r--editor/specialty/pnmindex.c15
2 files changed, 14 insertions, 3 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 030e2d0f..cc5f12cd 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -14,6 +14,8 @@ not yet  BJH  Release 11.05.00
               libnetpbm.  (Was fixed in 10.47.08 in November 2010, but only in
               the 10.47 series).
 
+              pnmindex: Improve failure mode when -size or -across is zero.
+
               pnmindex: Make -plain work.
 
               pnmpad: fix behavior with -left, -right, and -width together or
diff --git a/editor/specialty/pnmindex.c b/editor/specialty/pnmindex.c
index 86b70f42..d6c1764d 100644
--- a/editor/specialty/pnmindex.c
+++ b/editor/specialty/pnmindex.c
@@ -162,13 +162,22 @@ parseCommandLine(int argc, const char ** argv,
     if (quant && cmdlineP->noquant)
         pm_error("You can't specify both -quant and -noquat");
 
-    if (!colorsSpec)
+    if (colorsSpec) {
+        if (cmdlineP->colors == 0)
+            pm_error("-colors value must be positive");
+    } else
         cmdlineP->colors = 256;
 
-    if (!sizeSpec)
+    if (sizeSpec) {
+        if (cmdlineP->size == 0)
+            pm_error("-size value must be positive");
+    } else
         cmdlineP->size = 100;
 
-    if (!acrossSpec)
+    if (acrossSpec) {
+        if (cmdlineP->across == 0)
+            pm_error("-across value must be positive");
+    } else
         cmdlineP->across = 6;
 
     if (!titleSpec)