[libpng15] 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:42:52 -05:00
parent 2defb206e7
commit a5173354d2
3 changed files with 23 additions and 6 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.5.16beta05 - May 2, 2013
Libpng 1.5.16beta05 - 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.
@ -46,7 +46,9 @@ Version 1.5.16beta04 [May 1, 2013]
Expanded manual paragraph about writing private chunks, particularly
the need to call png_set_keep_unknown_chunks() when writing them.
Version 1.5.16beta05 [May 2, 2013]
Version 1.5.16beta05 [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

@ -4090,7 +4090,9 @@ Version 1.5.16beta04 [May 1, 2013]
Expanded manual paragraph about writing private chunks, particularly
the need to call png_set_keep_unknown_chunks() when writing them.
Version 1.5.16beta05 [May 2, 2013]
Version 1.5.16beta05 [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

@ -446,19 +446,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] != ' '));