[libpng17] Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart).

Ignore "#" delimited comments in input file to pnm2png.c.
This commit is contained in:
Glenn Randers-Pehrson 2013-05-07 14:38:19 -05:00
parent 6a02eb6d2c
commit 17c6af8c40
3 changed files with 23 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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] != ' '));