[libpng16] 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:31:35 -05:00
parent 2aa6c96e5d
commit db67cba8d4
4 changed files with 64 additions and 21 deletions

View File

@@ -4163,7 +4163,8 @@ png_read_finish_row(png_structrp png_ptr)
}
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
#ifdef PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED
#ifdef PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED
#if ZLIB_VERNUM > 0x1280
/* This is the code to to select a windowBits value to match the smallest
* possible sliding window needed to contain the entire uncompressed image.
*/
@@ -4230,6 +4231,7 @@ png_read_image_size(png_structrp png_ptr)
return 0xffffffffU;
}
#endif /* ZLIB_VERNUM */
#endif /* PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED */
void /* PRIVATE */
@@ -4516,23 +4518,37 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_free(png_ptr, buffer);
}
/* Finally claim the zstream for the inflate of the IDAT data, using the
* windowBts predicted from the uncompressed data size, not the value from
* the stream. If READ_OPTIMIZE_WINDOWBITS_SUPPORTED is not defined, then
* simply use a 32kbyte window (windowBits=15).
*
* To do: make this behavior optional via a run-time png_set_something(),
* with options to use windowBits=0 (use the zlib header data),
* windowBits=15 (use a 32kbyte window), or required_window_bits
* computed from the image size, pixel size, and interlacing setting.
*/
#ifdef PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED
if (png_inflate_claim(png_ptr, png_IDAT,
required_window_bits(png_read_image_size(png_ptr))) != Z_OK)
/* To do in libpng17: get windowBits from the CMF bytes and select the
* smaller of that and the required_window_bits. Requires a one-byte
* lookahead into the first IDAT chunk data, and requires actually
* injecting the revised CMF bytes into the datastream before reading.
*/
{
#if ZLIB_VERNUM < 0x1290
unsigned int windowBits;
#endif /* ZLIB_VERNUM */
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
{
#if ZLIB_VERNUM < 0x1290
windowBits=15;
#else
if (png_inflate_claim(png_ptr, png_IDAT, 15) != Z_OK)
/* Compute required windowBits from the image size, pixel size, and
* interlacing setting.
*/
windowBits=required_window_bits(png_read_image_size(png_ptr));
#endif /* ZLIB_VERNUM */
}
else
#endif
png_error(png_ptr, png_ptr->zstream.msg);
windowBits=0; /* Use the setting from the zlib CMF bytes */
/* Finally claim the zstream for the inflate of the IDAT data */
if (png_inflate_claim(png_ptr, png_IDAT, windowBits) != Z_OK)
png_error(png_ptr, png_ptr->zstream.msg);
}
png_ptr->flags |= PNG_FLAG_ROW_INIT;
}