diff options
author | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2013-05-07 14:38:19 -0500 |
---|---|---|
committer | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2013-05-07 14:38:19 -0500 |
commit | 17c6af8c40271e4d143dec8dff03384b7f09217f (patch) | |
tree | 478dcaf1f12849de15942c2593d35c065d072d72 | |
parent | 6a02eb6d2c9310a2ac82b7696a2e2814affff301 (diff) | |
download | libpng-17c6af8c40271e4d143dec8dff03384b7f09217f.tar.gz |
[libpng17] Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart).
Ignore "#" delimited comments in input file to pnm2png.c.
-rw-r--r-- | ANNOUNCE | 6 | ||||
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | contrib/pngminus/pnm2png.c | 19 |
3 files changed, 23 insertions, 6 deletions
@@ -1,5 +1,5 @@ -Libpng 1.7.0beta13 - April 30, 2013 +Libpng 1.7.0beta13 - May 7, 2013 This is not intended to be a public release. It will be replaced within a few weeks by a public version or by another test version. @@ -275,7 +275,9 @@ Version 1.7.0beta12 [April 30, 2013] Avoid dereferencing NULL pointer possibly returned from png_create_write_struct() (Andrew Church). -Version 1.7.0beta13 [April 30, 2013] +Version 1.7.0beta13 [May 7, 2013] + Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart). + Ignore "#" delimited comments in input file to pnm2png.c. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit @@ -4563,7 +4563,9 @@ Version 1.7.0beta12 [April 30, 2013] Avoid dereferencing NULL pointer possibly returned from png_create_write_struct() (Andrew Church). -Version 1.7.0beta13 [April 30, 2013] +Version 1.7.0beta13 [May 7, 2013] + Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart). + Ignore "#" delimited comments in input file to pnm2png.c. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/contrib/pngminus/pnm2png.c b/contrib/pngminus/pnm2png.c index d098e33cb..953011223 100644 --- a/contrib/pngminus/pnm2png.c +++ b/contrib/pngminus/pnm2png.c @@ -460,19 +460,32 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, void get_token(FILE *pnm_file, char *token) { int i = 0; + int ret; - /* remove white-space */ + /* remove white-space and comment lines */ do { - token[i] = (unsigned char) fgetc (pnm_file); + ret = fgetc(pnm_file); + if (ret == '#') { + /* the rest of this line is a comment */ + do + { + ret = fgetc(pnm_file); + } + while ((ret != '\n') && (ret != '\r') && (ret != EOF)); + } + if (ret == EOF) break; + token[i] = (unsigned char) ret; } while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' ')); /* read string */ do { + ret = fgetc(pnm_file); + if (ret == EOF) break; i++; - token[i] = (unsigned char) fgetc (pnm_file); + token[i] = (unsigned char) ret; } while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' ')); |