diff options
| author | Matthieu Darbois <mayeut@users.noreply.github.com> | 2014-11-22 14:09:16 +0000 |
|---|---|---|
| committer | Matthieu Darbois <mayeut@users.noreply.github.com> | 2014-11-22 14:09:16 +0000 |
| commit | 13bcb63b73008d949c0abc50270e397c665a6920 (patch) | |
| tree | 1435eea7a1d06a7aa86897d17708704ccdc4e2b5 /src | |
| parent | 0ba5d15b585a46a1b881e0a126a63225bedc767b (diff) | |
[trunk] fixed pnmtoimage for odd pgm files (fixes issue 294)
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/jp2/convert.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c index 7ada9a41..47d8b0be 100644 --- a/src/bin/jp2/convert.c +++ b/src/bin/jp2/convert.c @@ -1665,7 +1665,6 @@ static char *skip_idf(char *start, char out_idf[256]) static void read_pnm_header(FILE *reader, struct pnm_header *ph) { - char *s; int format, have_wh, end, ttype; char idf[256], type[256]; char line[256]; @@ -1691,6 +1690,8 @@ static void read_pnm_header(FILE *reader, struct pnm_header *ph) while(fgets(line, 250, reader)) { + char *s; + if(*line == '#') continue; s = line; @@ -1774,7 +1775,18 @@ static void read_pnm_header(FILE *reader, struct pnm_header *ph) have_wh = 1; if(format == 1 || format == 4) break; - + + if(format == 2 || format == 3 || format == 5 || format == 6) + { + if (skip_int(s, &ph->maxval) != NULL) { + if(ph->maxval > 65535) { + return; + } + else { + break; + } + } + } continue; } if(format == 2 || format == 3 || format == 5 || format == 6) |
