diff --git a/ANNOUNCE b/ANNOUNCE index 12d8c767f..0146b7eac 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -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 diff --git a/CHANGES b/CHANGES index 816deb354..36ae1db1a 100644 --- a/CHANGES +++ b/CHANGES @@ -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] != ' '));