From 3c774f1903062eb53ae06274f56e521a925ba996 Mon Sep 17 00:00:00 2001
From: Su_Laus <[EMAIL REDACTED]>
Date: Thu, 12 Jan 2023 22:33:46 +0100
Subject: [PATCH] tiffmedian: avoid zero num_colors, fixes #477
---
tools/tiffmedian.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/tiffmedian.c b/tools/tiffmedian.c
index 8225970c..334566a4 100644
--- a/tools/tiffmedian.c
+++ b/tools/tiffmedian.c
@@ -144,10 +144,15 @@ int main(int argc, char *argv[])
num_colors = atoi(optarg);
if (num_colors > MAX_CMAP_SIZE)
{
- fprintf(stderr, "-c: colormap too big, max %d\n",
+ fprintf(stderr, "-C: colormap too big, max %d\n",
MAX_CMAP_SIZE);
usage(EXIT_FAILURE);
}
+ if (num_colors < 2)
+ {
+ fprintf(stderr, "-C: colormap too small, min %d\n", 2);
+ usage(EXIT_FAILURE);
+ }
break;
case 'f': /* dither */
dither = 1;