diff options
Diffstat (limited to 'plugins/FreeImage/Source/LibPNG/pngpread.c')
-rw-r--r-- | plugins/FreeImage/Source/LibPNG/pngpread.c | 259 |
1 files changed, 123 insertions, 136 deletions
diff --git a/plugins/FreeImage/Source/LibPNG/pngpread.c b/plugins/FreeImage/Source/LibPNG/pngpread.c index e19a8c7bca..eda5a6c80f 100644 --- a/plugins/FreeImage/Source/LibPNG/pngpread.c +++ b/plugins/FreeImage/Source/LibPNG/pngpread.c @@ -1,7 +1,7 @@ /* pngpread.c - read a png file in push mode
*
- * Last changed in libpng 1.5.2 [March 31, 2011]
+ * Last changed in libpng 1.5.9 [February 18, 2012]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -208,61 +208,7 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr) void /* PRIVATE */
png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
{
- PNG_IHDR;
- PNG_IDAT;
- PNG_IEND;
- PNG_PLTE;
-#ifdef PNG_READ_bKGD_SUPPORTED
- PNG_bKGD;
-#endif
-#ifdef PNG_READ_cHRM_SUPPORTED
- PNG_cHRM;
-#endif
-#ifdef PNG_READ_gAMA_SUPPORTED
- PNG_gAMA;
-#endif
-#ifdef PNG_READ_hIST_SUPPORTED
- PNG_hIST;
-#endif
-#ifdef PNG_READ_iCCP_SUPPORTED
- PNG_iCCP;
-#endif
-#ifdef PNG_READ_iTXt_SUPPORTED
- PNG_iTXt;
-#endif
-#ifdef PNG_READ_oFFs_SUPPORTED
- PNG_oFFs;
-#endif
-#ifdef PNG_READ_pCAL_SUPPORTED
- PNG_pCAL;
-#endif
-#ifdef PNG_READ_pHYs_SUPPORTED
- PNG_pHYs;
-#endif
-#ifdef PNG_READ_sBIT_SUPPORTED
- PNG_sBIT;
-#endif
-#ifdef PNG_READ_sCAL_SUPPORTED
- PNG_sCAL;
-#endif
-#ifdef PNG_READ_sRGB_SUPPORTED
- PNG_sRGB;
-#endif
-#ifdef PNG_READ_sPLT_SUPPORTED
- PNG_sPLT;
-#endif
-#ifdef PNG_READ_tEXt_SUPPORTED
- PNG_tEXt;
-#endif
-#ifdef PNG_READ_tIME_SUPPORTED
- PNG_tIME;
-#endif
-#ifdef PNG_READ_tRNS_SUPPORTED
- PNG_tRNS;
-#endif
-#ifdef PNG_READ_zTXt_SUPPORTED
- PNG_zTXt;
-#endif
+ png_uint_32 chunk_name;
/* First we make sure we have enough data for the 4 byte chunk name
* and the 4 byte chunk length before proceeding with decoding the
@@ -273,6 +219,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
{
png_byte chunk_length[4];
+ png_byte chunk_tag[4];
if (png_ptr->buffer_size < 8)
{
@@ -283,16 +230,27 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_fill_buffer(png_ptr, chunk_length, 4);
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr);
- png_crc_read(png_ptr, png_ptr->chunk_name, 4);
+ png_crc_read(png_ptr, chunk_tag, 4);
+ png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
}
- if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+ chunk_name = png_ptr->chunk_name;
+
+ if (chunk_name == png_IDAT)
+ {
+ /* This is here above the if/else case statement below because if the
+ * unknown handling marks 'IDAT' as unknown then the IDAT handling case is
+ * completely skipped.
+ *
+ * TODO: there must be a better way of doing this.
+ */
if (png_ptr->mode & PNG_AFTER_IDAT)
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
+ }
- if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
+ if (chunk_name == png_IHDR)
{
if (png_ptr->push_length != 13)
png_error(png_ptr, "Invalid IHDR length");
@@ -306,7 +264,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
}
- else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
+ else if (chunk_name == png_IEND)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -321,7 +279,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) }
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
+ else if (png_chunk_unknown_handling(png_ptr, chunk_name))
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -329,15 +287,15 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) return;
}
- if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+ if (chunk_name == png_IDAT)
png_ptr->mode |= PNG_HAVE_IDAT;
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
- if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
+ if (chunk_name == png_PLTE)
png_ptr->mode |= PNG_HAVE_PLTE;
- else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+ else if (chunk_name == png_IDAT)
{
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before IDAT");
@@ -349,7 +307,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) }
#endif
- else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
+ else if (chunk_name == png_PLTE)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -359,7 +317,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
}
- else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+ else if (chunk_name == png_IDAT)
{
/* If we reach an IDAT chunk, this means we have read all of the
* header chunks, and we can start reading the image (or if this
@@ -395,7 +353,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) }
#ifdef PNG_READ_gAMA_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
+ else if (png_ptr->chunk_name == png_gAMA)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -408,7 +366,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_sBIT_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
+ else if (png_ptr->chunk_name == png_sBIT)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -421,7 +379,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_cHRM_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
+ else if (png_ptr->chunk_name == png_cHRM)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -434,7 +392,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_sRGB_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
+ else if (chunk_name == png_sRGB)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -447,7 +405,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_iCCP_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
+ else if (png_ptr->chunk_name == png_iCCP)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -460,7 +418,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_sPLT_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
+ else if (chunk_name == png_sPLT)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -473,7 +431,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_tRNS_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
+ else if (chunk_name == png_tRNS)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -486,7 +444,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_bKGD_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
+ else if (chunk_name == png_bKGD)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -499,7 +457,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_hIST_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4))
+ else if (chunk_name == png_hIST)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -512,7 +470,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_pHYs_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
+ else if (chunk_name == png_pHYs)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -525,7 +483,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_oFFs_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
+ else if (chunk_name == png_oFFs)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -538,7 +496,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_pCAL_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
+ else if (chunk_name == png_pCAL)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -551,7 +509,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_sCAL_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
+ else if (chunk_name == png_sCAL)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -564,7 +522,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_tIME_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
+ else if (chunk_name == png_tIME)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -577,7 +535,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_tEXt_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
+ else if (chunk_name == png_tEXt)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -590,7 +548,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_zTXt_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
+ else if (chunk_name == png_zTXt)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -603,7 +561,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) #endif
#ifdef PNG_READ_iTXt_SUPPORTED
- else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
+ else if (chunk_name == png_iTXt)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
@@ -772,8 +730,7 @@ png_push_save_buffer(png_structp png_ptr) new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
old_buffer = png_ptr->save_buffer;
- png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr,
- (png_size_t)new_max);
+ png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr, new_max);
if (png_ptr->save_buffer == NULL)
{
@@ -809,11 +766,12 @@ png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, void /* PRIVATE */
png_push_read_IDAT(png_structp png_ptr)
{
- PNG_IDAT;
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
{
png_byte chunk_length[4];
+ png_byte chunk_tag[4];
+ /* TODO: this code can be commoned up with the same code in push_read */
if (png_ptr->buffer_size < 8)
{
png_push_save_buffer(png_ptr);
@@ -823,10 +781,11 @@ png_push_read_IDAT(png_structp png_ptr) png_push_fill_buffer(png_ptr, chunk_length, 4);
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr);
- png_crc_read(png_ptr, png_ptr->chunk_name, 4);
+ png_crc_read(png_ptr, chunk_tag, 4);
+ png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
- if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+ if (png_ptr->chunk_name != png_IDAT)
{
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
@@ -838,6 +797,7 @@ png_push_read_IDAT(png_structp png_ptr) png_ptr->idat_size = png_ptr->push_length;
}
+
if (png_ptr->idat_size && png_ptr->save_buffer_size)
{
png_size_t save_size = png_ptr->save_buffer_size;
@@ -1011,36 +971,56 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, void /* PRIVATE */
png_push_process_row(png_structp png_ptr)
{
- png_ptr->row_info.color_type = png_ptr->color_type;
- png_ptr->row_info.width = png_ptr->iwidth;
- png_ptr->row_info.channels = png_ptr->channels;
- png_ptr->row_info.bit_depth = png_ptr->bit_depth;
- png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
+ /* 1.5.6: row_info moved out of png_struct to a local here. */
+ png_row_info row_info;
- png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
- png_ptr->row_info.width);
+ row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */
+ row_info.color_type = png_ptr->color_type;
+ row_info.bit_depth = png_ptr->bit_depth;
+ row_info.channels = png_ptr->channels;
+ row_info.pixel_depth = png_ptr->pixel_depth;
+ row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
- png_read_filter_row(png_ptr, &(png_ptr->row_info),
- png_ptr->row_buf + 1, png_ptr->prev_row + 1,
- (int)(png_ptr->row_buf[0]));
+ if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)
+ {
+ if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)
+ png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,
+ png_ptr->prev_row + 1, png_ptr->row_buf[0]);
+ else
+ png_error(png_ptr, "bad adaptive filter value");
+ }
- png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
+ /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before
+ * 1.5.6, while the buffer really is this big in current versions of libpng
+ * it may not be in the future, so this was changed just to copy the
+ * interlaced row count:
+ */
+ png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
if (png_ptr->transformations)
- png_do_read_transformations(png_ptr);
+ png_do_read_transformations(png_ptr, &row_info);
#endif
+ /* The transformed pixel depth should match the depth now in row_info. */
+ if (png_ptr->transformed_pixel_depth == 0)
+ {
+ png_ptr->transformed_pixel_depth = row_info.pixel_depth;
+ if (row_info.pixel_depth > png_ptr->maximum_pixel_depth)
+ png_error(png_ptr, "progressive row overflow");
+ }
+
+ else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth)
+ png_error(png_ptr, "internal progressive row size calculation error");
+
+
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Blow up interlaced rows to full size */
if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
{
if (png_ptr->pass < 6)
-/* old interface (pre-1.0.9):
- png_do_read_interlace(&(png_ptr->row_info),
- png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
- */
- png_do_read_interlace(png_ptr);
+ png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
+ png_ptr->transformations);
switch (png_ptr->pass)
{
@@ -1220,24 +1200,26 @@ png_push_process_row(png_structp png_ptr) void /* PRIVATE */
png_read_push_finish_row(png_structp png_ptr)
{
+#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */
- PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
+ static PNG_CONST png_byte FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
/* Offset to next interlace block */
- PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
+ static PNG_CONST png_byte FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
/* Start of interlace block in the y direction */
- PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
+ static PNG_CONST png_byte FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
/* Offset to next interlace block in the y direction */
- PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
+ static PNG_CONST png_byte FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
/* Height of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h
- PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
+ static PNG_CONST png_byte FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
*/
+#endif
png_ptr->row_number++;
if (png_ptr->row_number < png_ptr->num_rows)
@@ -1304,8 +1286,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 }
#endif
- png_ptr->current_text = (png_charp)png_malloc(png_ptr,
- (png_size_t)(length + 1));
+ png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1);
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = (png_size_t)length;
@@ -1403,8 +1384,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 }
#endif
- png_ptr->current_text = (png_charp)png_malloc(png_ptr,
- (png_size_t)(length + 1));
+ png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1);
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = (png_size_t)length;
@@ -1605,8 +1585,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 }
#endif
- png_ptr->current_text = (png_charp)png_malloc(png_ptr,
- (png_size_t)(length + 1));
+ png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1);
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = (png_size_t)length;
@@ -1714,11 +1693,12 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_uint_32 skip = 0;
+ png_uint_32 chunk_name = png_ptr->chunk_name;
- if (!(png_ptr->chunk_name[0] & 0x20))
+ if (PNG_CHUNK_CRITICAL(chunk_name))
{
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
- if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
+ if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
&& png_ptr->read_user_chunk_fn == NULL
@@ -1731,23 +1711,26 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 }
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
+ /* TODO: the code below is apparently just using the
+ * png_struct::unknown_chunk member as a temporarily variable, it should be
+ * possible to eliminate both it and the temporary buffer.
+ */
if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
{
#ifdef PNG_MAX_MALLOC_64K
- if (length > (png_uint_32)65535L)
+ if (length > 65535)
{
png_warning(png_ptr, "unknown chunk too large to fit in memory");
- skip = length - (png_uint_32)65535L;
- length = (png_uint_32)65535L;
+ skip = length - 65535;
+ length = 65535;
}
#endif
- png_memcpy((png_charp)png_ptr->unknown_chunk.name,
- (png_charp)png_ptr->chunk_name,
- png_sizeof(png_ptr->unknown_chunk.name));
- png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name) - 1]
- = '\0';
+ /* This is just a record for the user; libpng doesn't use the character
+ * form of the name.
+ */
+ PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name);
- png_ptr->unknown_chunk.size = (png_size_t)length;
+ png_ptr->unknown_chunk.size = length;
if (length == 0)
png_ptr->unknown_chunk.data = NULL;
@@ -1755,8 +1738,9 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 else
{
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr,
- (png_size_t)length);
- png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
+ png_ptr->unknown_chunk.size);
+ png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data,
+ png_ptr->unknown_chunk.size);
}
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
@@ -1772,8 +1756,8 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 if (ret == 0)
{
- if (!(png_ptr->chunk_name[0] & 0x20))
- if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
+ if (PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
+ if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS)
png_chunk_error(png_ptr, "unknown critical chunk");
png_set_unknown_chunks(png_ptr, info_ptr,
@@ -1816,19 +1800,22 @@ png_push_have_row(png_structp png_ptr, png_bytep row) (int)png_ptr->pass);
}
+#ifdef PNG_READ_INTERLACING_SUPPORTED
void PNGAPI
png_progressive_combine_row (png_structp png_ptr, png_bytep old_row,
png_const_bytep new_row)
{
- PNG_CONST int FARDATA png_pass_dsp_mask[7] =
- {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
-
if (png_ptr == NULL)
return;
- if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */
- png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
+ /* new_row is a flag here - if it is NULL then the app callback was called
+ * from an empty row (see the calls to png_struct::row_fn below), otherwise
+ * it must be png_ptr->row_buf+1
+ */
+ if (new_row != NULL)
+ png_combine_row(png_ptr, old_row, 1/*display*/);
}
+#endif /* PNG_READ_INTERLACING_SUPPORTED */
void PNGAPI
png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
|