summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-01-19 19:42:20 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-01-19 19:42:20 +0100
commit8e89c927d9755c1efccdd02df2c6a0074305fff6 (patch)
tree283c8eab5a8045c19288a30a09374e5f6dc53cba /src
parente01f8bfc8d9569a32a57307cede06e3da7f558a8 (diff)
fix check for too small tables
Diffstat (limited to 'src')
-rw-r--r--src/pnmcurve.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/pnmcurve.c b/src/pnmcurve.c
index 4ddbc5c..7910536 100644
--- a/src/pnmcurve.c
+++ b/src/pnmcurve.c
@@ -66,17 +66,17 @@ main(int argc, char **argv) {
if (!curve) {
usage();
- exit(1);
+ return 1;
}
if (readPnmHeader(stdin, &in_pnm) != 0) {
fprintf(stderr, "failed to read PNM file\n");
- exit(1);
+ return 1;
}
if (in_pnm.maxval != 255 && in_pnm.maxval != 65535) {
fprintf(stderr, "unsupported PNM maxval %d\n", in_pnm.maxval);
- exit(1);
+ return 1;
}
if (channels == 0) channels = RED | GREEN | BLUE;
@@ -94,9 +94,7 @@ main(int argc, char **argv) {
writePnmHeader(stdout, &in_pnm);
- pam_transform(stdin, stdout, &in_pnm, gTable);
-
- return 0;
+ return pam_transform(stdin, stdout, &in_pnm, gTable);
}
static int
@@ -107,7 +105,7 @@ pam_transform(FILE *in_fp, FILE *out_fp,
unsigned char *buf = malloc(in_pnm->width * nbytes * 3);
for (c = 0; c < 3; c++) {
- if (tables[c] && tables[c]->n <= in_pnm->maxval) {
+ if (tables[c] && tables[c]->n < 1 << (nbytes * 8)) {
fprintf(stderr, "table %d too small (%d)\n", c, tables[c]->n);
return 1;
}