| Index: third_party/libpng/pngread.c
|
| ===================================================================
|
| --- third_party/libpng/pngread.c (revision 7204)
|
| +++ third_party/libpng/pngread.c (working copy)
|
| @@ -1,7 +1,7 @@
|
|
|
| /* pngread.c - read a PNG file
|
| *
|
| - * Last changed in libpng 1.2.25 [February 18, 2008]
|
| + * Last changed in libpng 1.2.30 [August 15, 2008]
|
| * For conditions of distribution and use, see copyright notice in png.h
|
| * Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
| * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
| @@ -13,7 +13,6 @@
|
|
|
| #define PNG_INTERNAL
|
| #include "png.h"
|
| -
|
| #if defined(PNG_READ_SUPPORTED)
|
|
|
| /* Create a PNG structure for reading, and allocate any memory needed. */
|
| @@ -35,6 +34,9 @@
|
| {
|
| #endif /* PNG_USER_MEM_SUPPORTED */
|
|
|
| +#ifdef PNG_SETJMP_SUPPORTED
|
| + volatile
|
| +#endif
|
| png_structp png_ptr;
|
|
|
| #ifdef PNG_SETJMP_SUPPORTED
|
| @@ -69,7 +71,7 @@
|
| #endif
|
| {
|
| png_free(png_ptr, png_ptr->zbuf);
|
| - png_ptr->zbuf=NULL;
|
| + png_ptr->zbuf = NULL;
|
| #ifdef PNG_USER_MEM_SUPPORTED
|
| png_destroy_struct_2((png_voidp)png_ptr,
|
| (png_free_ptr)free_fn, (png_voidp)mem_ptr);
|
| @@ -79,7 +81,7 @@
|
| return (NULL);
|
| }
|
| #ifdef USE_FAR_KEYWORD
|
| - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
|
| + png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf));
|
| #endif
|
| #endif
|
|
|
| @@ -89,12 +91,12 @@
|
|
|
| png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
|
|
| - if(user_png_ver)
|
| + if (user_png_ver)
|
| {
|
| - i=0;
|
| + i = 0;
|
| do
|
| {
|
| - if(user_png_ver[i] != png_libpng_ver[i])
|
| + if (user_png_ver[i] != png_libpng_ver[i])
|
| png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
| } while (png_libpng_ver[i++]);
|
| }
|
| @@ -128,7 +130,7 @@
|
| png_warning(png_ptr, msg);
|
| #endif
|
| #ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
| - png_ptr->flags=0;
|
| + png_ptr->flags = 0;
|
| #endif
|
| png_error(png_ptr,
|
| "Incompatible libpng version in application and library");
|
| @@ -164,7 +166,7 @@
|
| #ifdef USE_FAR_KEYWORD
|
| if (setjmp(jmpbuf))
|
| PNG_ABORT();
|
| - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
|
| + png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf));
|
| #else
|
| if (setjmp(png_ptr->jmpbuf))
|
| PNG_ABORT();
|
| @@ -190,13 +192,13 @@
|
| png_size_t png_struct_size, png_size_t png_info_size)
|
| {
|
| /* We only come here via pre-1.0.12-compiled applications */
|
| - if(png_ptr == NULL) return;
|
| + if (png_ptr == NULL) return;
|
| #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
| - if(png_sizeof(png_struct) > png_struct_size ||
|
| + if (png_sizeof(png_struct) > png_struct_size ||
|
| png_sizeof(png_info) > png_info_size)
|
| {
|
| char msg[80];
|
| - png_ptr->warning_fn=NULL;
|
| + png_ptr->warning_fn = NULL;
|
| if (user_png_ver)
|
| {
|
| png_snprintf(msg, 80,
|
| @@ -210,20 +212,20 @@
|
| png_warning(png_ptr, msg);
|
| }
|
| #endif
|
| - if(png_sizeof(png_struct) > png_struct_size)
|
| + if (png_sizeof(png_struct) > png_struct_size)
|
| {
|
| - png_ptr->error_fn=NULL;
|
| + png_ptr->error_fn = NULL;
|
| #ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
| - png_ptr->flags=0;
|
| + png_ptr->flags = 0;
|
| #endif
|
| png_error(png_ptr,
|
| "The png struct allocated by the application for reading is too small.");
|
| }
|
| - if(png_sizeof(png_info) > png_info_size)
|
| + if (png_sizeof(png_info) > png_info_size)
|
| {
|
| - png_ptr->error_fn=NULL;
|
| + png_ptr->error_fn = NULL;
|
| #ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
| - png_ptr->flags=0;
|
| + png_ptr->flags = 0;
|
| #endif
|
| png_error(png_ptr,
|
| "The info struct allocated by application for reading is too small.");
|
| @@ -240,20 +242,20 @@
|
| jmp_buf tmp_jmp; /* to save current jump buffer */
|
| #endif
|
|
|
| - int i=0;
|
| + int i = 0;
|
|
|
| png_structp png_ptr=*ptr_ptr;
|
|
|
| - if(png_ptr == NULL) return;
|
| + if (png_ptr == NULL) return;
|
|
|
| do
|
| {
|
| - if(user_png_ver[i] != png_libpng_ver[i])
|
| + if (user_png_ver[i] != png_libpng_ver[i])
|
| {
|
| #ifdef PNG_LEGACY_SUPPORTED
|
| png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
| #else
|
| - png_ptr->warning_fn=NULL;
|
| + png_ptr->warning_fn = NULL;
|
| png_warning(png_ptr,
|
| "Application uses deprecated png_read_init() and should be recompiled.");
|
| break;
|
| @@ -265,22 +267,22 @@
|
|
|
| #ifdef PNG_SETJMP_SUPPORTED
|
| /* save jump buffer and error functions */
|
| - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
|
| + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
| #endif
|
|
|
| - if(png_sizeof(png_struct) > png_struct_size)
|
| - {
|
| - png_destroy_struct(png_ptr);
|
| - *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
|
| - png_ptr = *ptr_ptr;
|
| - }
|
| + if (png_sizeof(png_struct) > png_struct_size)
|
| + {
|
| + png_destroy_struct(png_ptr);
|
| + *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
|
| + png_ptr = *ptr_ptr;
|
| + }
|
|
|
| /* reset all variables to 0 */
|
| - png_memset(png_ptr, 0, png_sizeof (png_struct));
|
| + png_memset(png_ptr, 0, png_sizeof(png_struct));
|
|
|
| #ifdef PNG_SETJMP_SUPPORTED
|
| /* restore jump buffer */
|
| - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
|
| + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
|
| #endif
|
|
|
| /* added at libpng-1.2.6 */
|
| @@ -324,7 +326,7 @@
|
| void PNGAPI
|
| png_read_info(png_structp png_ptr, png_infop info_ptr)
|
| {
|
| - if(png_ptr == NULL || info_ptr == NULL) return;
|
| + if (png_ptr == NULL || info_ptr == NULL) return;
|
| png_debug(1, "in png_read_info\n");
|
| /* If we haven't checked all of the PNG signature bytes, do so now. */
|
| if (png_ptr->sig_bytes < 8)
|
| @@ -347,7 +349,7 @@
|
| png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
|
| }
|
|
|
| - for(;;)
|
| + for (;;)
|
| {
|
| #ifdef PNG_USE_LOCAL_ARRAYS
|
| PNG_CONST PNG_IHDR;
|
| @@ -406,38 +408,29 @@
|
| PNG_CONST PNG_zTXt;
|
| #endif
|
| #endif /* PNG_USE_LOCAL_ARRAYS */
|
| - png_byte chunk_length[4];
|
| - png_uint_32 length;
|
| + png_uint_32 length = png_read_chunk_header(png_ptr);
|
| + PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
|
|
|
| - png_read_data(png_ptr, chunk_length, 4);
|
| - 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_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name,
|
| - length);
|
| -
|
| /* This should be a binary subdivision search or a hash for
|
| * matching the chunk name rather than a linear search.
|
| */
|
| - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
| - if(png_ptr->mode & PNG_AFTER_IDAT)
|
| + if (!png_memcmp(chunk_name, png_IDAT, 4))
|
| + 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 (!png_memcmp(chunk_name, png_IHDR, 4))
|
| png_handle_IHDR(png_ptr, info_ptr, length);
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
| + else if (!png_memcmp(chunk_name, png_IEND, 4))
|
| png_handle_IEND(png_ptr, info_ptr, length);
|
| #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
| - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
|
| + else if (png_handle_as_unknown(png_ptr, chunk_name))
|
| {
|
| - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
| + if (!png_memcmp(chunk_name, png_IDAT, 4))
|
| png_ptr->mode |= PNG_HAVE_IDAT;
|
| png_handle_unknown(png_ptr, info_ptr, length);
|
| - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
| + if (!png_memcmp(chunk_name, png_PLTE, 4))
|
| png_ptr->mode |= PNG_HAVE_PLTE;
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
| + else if (!png_memcmp(chunk_name, png_IDAT, 4))
|
| {
|
| if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
| png_error(png_ptr, "Missing IHDR before IDAT");
|
| @@ -448,9 +441,9 @@
|
| }
|
| }
|
| #endif
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
| + else if (!png_memcmp(chunk_name, png_PLTE, 4))
|
| png_handle_PLTE(png_ptr, info_ptr, length);
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
| + else if (!png_memcmp(chunk_name, png_IDAT, 4))
|
| {
|
| if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
| png_error(png_ptr, "Missing IHDR before IDAT");
|
| @@ -463,71 +456,71 @@
|
| break;
|
| }
|
| #if defined(PNG_READ_bKGD_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
|
| + else if (!png_memcmp(chunk_name, png_bKGD, 4))
|
| png_handle_bKGD(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_cHRM_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
|
| + else if (!png_memcmp(chunk_name, png_cHRM, 4))
|
| png_handle_cHRM(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_gAMA_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
|
| + else if (!png_memcmp(chunk_name, png_gAMA, 4))
|
| png_handle_gAMA(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_hIST_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4))
|
| + else if (!png_memcmp(chunk_name, png_hIST, 4))
|
| png_handle_hIST(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_oFFs_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
|
| + else if (!png_memcmp(chunk_name, png_oFFs, 4))
|
| png_handle_oFFs(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_pCAL_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
|
| + else if (!png_memcmp(chunk_name, png_pCAL, 4))
|
| png_handle_pCAL(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_sCAL_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
|
| + else if (!png_memcmp(chunk_name, png_sCAL, 4))
|
| png_handle_sCAL(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_pHYs_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
|
| + else if (!png_memcmp(chunk_name, png_pHYs, 4))
|
| png_handle_pHYs(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_sBIT_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
|
| + else if (!png_memcmp(chunk_name, png_sBIT, 4))
|
| png_handle_sBIT(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_sRGB_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
|
| + else if (!png_memcmp(chunk_name, png_sRGB, 4))
|
| png_handle_sRGB(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_iCCP_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
|
| + else if (!png_memcmp(chunk_name, png_iCCP, 4))
|
| png_handle_iCCP(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_sPLT_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
|
| + else if (!png_memcmp(chunk_name, png_sPLT, 4))
|
| png_handle_sPLT(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_tEXt_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
| + else if (!png_memcmp(chunk_name, png_tEXt, 4))
|
| png_handle_tEXt(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_tIME_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
|
| + else if (!png_memcmp(chunk_name, png_tIME, 4))
|
| png_handle_tIME(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_tRNS_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
|
| + else if (!png_memcmp(chunk_name, png_tRNS, 4))
|
| png_handle_tRNS(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_zTXt_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
|
| + else if (!png_memcmp(chunk_name, png_zTXt, 4))
|
| png_handle_zTXt(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_iTXt_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
|
| + else if (!png_memcmp(chunk_name, png_iTXt, 4))
|
| png_handle_iTXt(png_ptr, info_ptr, length);
|
| #endif
|
| else
|
| @@ -541,7 +534,7 @@
|
| png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
| {
|
| png_debug(1, "in png_read_update_info\n");
|
| - if(png_ptr == NULL) return;
|
| + if (png_ptr == NULL) return;
|
| if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
| png_read_start_row(png_ptr);
|
| else
|
| @@ -560,7 +553,7 @@
|
| png_start_read_image(png_structp png_ptr)
|
| {
|
| png_debug(1, "in png_start_read_image\n");
|
| - if(png_ptr == NULL) return;
|
| + if (png_ptr == NULL) return;
|
| if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
| png_read_start_row(png_ptr);
|
| }
|
| @@ -573,11 +566,11 @@
|
| #ifdef PNG_USE_LOCAL_ARRAYS
|
| PNG_CONST PNG_IDAT;
|
| PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
|
| - 0xff};
|
| + 0xff};
|
| PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
| #endif
|
| int ret;
|
| - if(png_ptr == NULL) return;
|
| + if (png_ptr == NULL) return;
|
| png_debug2(1, "in png_read_row (row %lu, pass %d)\n",
|
| png_ptr->row_number, png_ptr->pass);
|
| if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
| @@ -703,15 +696,9 @@
|
| {
|
| while (!png_ptr->idat_size)
|
| {
|
| - png_byte chunk_length[4];
|
| -
|
| png_crc_finish(png_ptr, 0);
|
|
|
| - png_read_data(png_ptr, chunk_length, 4);
|
| - png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length);
|
| -
|
| - png_reset_crc(png_ptr);
|
| - png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
| + png_ptr->idat_size = png_read_chunk_header(png_ptr);
|
| if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
| png_error(png_ptr, "Not enough image data");
|
| }
|
| @@ -747,7 +734,7 @@
|
| png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
|
| png_ptr->row_info.width);
|
|
|
| - if(png_ptr->row_buf[0])
|
| + if (png_ptr->row_buf[0])
|
| 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]));
|
| @@ -756,7 +743,7 @@
|
| png_ptr->rowbytes + 1);
|
|
|
| #if defined(PNG_MNG_FEATURES_SUPPORTED)
|
| - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
| + if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
| (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
|
| {
|
| /* Intrapixel differencing */
|
| @@ -836,7 +823,7 @@
|
| png_bytepp dp;
|
|
|
| png_debug(1, "in png_read_rows\n");
|
| - if(png_ptr == NULL) return;
|
| + if (png_ptr == NULL) return;
|
| rp = row;
|
| dp = display_row;
|
| if (rp != NULL && dp != NULL)
|
| @@ -847,14 +834,14 @@
|
|
|
| png_read_row(png_ptr, rptr, dptr);
|
| }
|
| - else if(rp != NULL)
|
| + else if (rp != NULL)
|
| for (i = 0; i < num_rows; i++)
|
| {
|
| png_bytep rptr = *rp;
|
| png_read_row(png_ptr, rptr, png_bytep_NULL);
|
| rp++;
|
| }
|
| - else if(dp != NULL)
|
| + else if (dp != NULL)
|
| for (i = 0; i < num_rows; i++)
|
| {
|
| png_bytep dptr = *dp;
|
| @@ -880,12 +867,12 @@
|
| void PNGAPI
|
| png_read_image(png_structp png_ptr, png_bytepp image)
|
| {
|
| - png_uint_32 i,image_height;
|
| + png_uint_32 i, image_height;
|
| int pass, j;
|
| png_bytepp rp;
|
|
|
| png_debug(1, "in png_read_image\n");
|
| - if(png_ptr == NULL) return;
|
| + if (png_ptr == NULL) return;
|
|
|
| #ifdef PNG_READ_INTERLACING_SUPPORTED
|
| pass = png_set_interlace_handling(png_ptr);
|
| @@ -920,11 +907,8 @@
|
| void PNGAPI
|
| png_read_end(png_structp png_ptr, png_infop info_ptr)
|
| {
|
| - png_byte chunk_length[4];
|
| - png_uint_32 length;
|
| -
|
| png_debug(1, "in png_read_end\n");
|
| - if(png_ptr == NULL) return;
|
| + if (png_ptr == NULL) return;
|
| png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
|
|
|
| do
|
| @@ -986,33 +970,27 @@
|
| PNG_CONST PNG_zTXt;
|
| #endif
|
| #endif /* PNG_USE_LOCAL_ARRAYS */
|
| + png_uint_32 length = png_read_chunk_header(png_ptr);
|
| + PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
|
|
|
| - png_read_data(png_ptr, chunk_length, 4);
|
| - 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_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name);
|
| -
|
| - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
|
| + if (!png_memcmp(chunk_name, png_IHDR, 4))
|
| png_handle_IHDR(png_ptr, info_ptr, length);
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
| + else if (!png_memcmp(chunk_name, png_IEND, 4))
|
| png_handle_IEND(png_ptr, info_ptr, length);
|
| #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
| - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
|
| + else if (png_handle_as_unknown(png_ptr, chunk_name))
|
| {
|
| - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
| + if (!png_memcmp(chunk_name, png_IDAT, 4))
|
| {
|
| if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
| png_error(png_ptr, "Too many IDAT's found");
|
| }
|
| png_handle_unknown(png_ptr, info_ptr, length);
|
| - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
| + if (!png_memcmp(chunk_name, png_PLTE, 4))
|
| png_ptr->mode |= PNG_HAVE_PLTE;
|
| }
|
| #endif
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
| + else if (!png_memcmp(chunk_name, png_IDAT, 4))
|
| {
|
| /* Zero length IDATs are legal after the last IDAT has been
|
| * read, but not after other chunks have been read.
|
| @@ -1021,74 +999,74 @@
|
| png_error(png_ptr, "Too many IDAT's found");
|
| png_crc_finish(png_ptr, length);
|
| }
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
| + else if (!png_memcmp(chunk_name, png_PLTE, 4))
|
| png_handle_PLTE(png_ptr, info_ptr, length);
|
| #if defined(PNG_READ_bKGD_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
|
| + else if (!png_memcmp(chunk_name, png_bKGD, 4))
|
| png_handle_bKGD(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_cHRM_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
|
| + else if (!png_memcmp(chunk_name, png_cHRM, 4))
|
| png_handle_cHRM(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_gAMA_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
|
| + else if (!png_memcmp(chunk_name, png_gAMA, 4))
|
| png_handle_gAMA(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_hIST_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4))
|
| + else if (!png_memcmp(chunk_name, png_hIST, 4))
|
| png_handle_hIST(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_oFFs_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
|
| + else if (!png_memcmp(chunk_name, png_oFFs, 4))
|
| png_handle_oFFs(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_pCAL_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
|
| + else if (!png_memcmp(chunk_name, png_pCAL, 4))
|
| png_handle_pCAL(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_sCAL_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
|
| + else if (!png_memcmp(chunk_name, png_sCAL, 4))
|
| png_handle_sCAL(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_pHYs_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
|
| + else if (!png_memcmp(chunk_name, png_pHYs, 4))
|
| png_handle_pHYs(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_sBIT_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
|
| + else if (!png_memcmp(chunk_name, png_sBIT, 4))
|
| png_handle_sBIT(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_sRGB_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
|
| + else if (!png_memcmp(chunk_name, png_sRGB, 4))
|
| png_handle_sRGB(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_iCCP_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
|
| + else if (!png_memcmp(chunk_name, png_iCCP, 4))
|
| png_handle_iCCP(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_sPLT_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
|
| + else if (!png_memcmp(chunk_name, png_sPLT, 4))
|
| png_handle_sPLT(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_tEXt_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
| + else if (!png_memcmp(chunk_name, png_tEXt, 4))
|
| png_handle_tEXt(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_tIME_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
|
| + else if (!png_memcmp(chunk_name, png_tIME, 4))
|
| png_handle_tIME(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_tRNS_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
|
| + else if (!png_memcmp(chunk_name, png_tRNS, 4))
|
| png_handle_tRNS(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_zTXt_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
|
| + else if (!png_memcmp(chunk_name, png_zTXt, 4))
|
| png_handle_zTXt(png_ptr, info_ptr, length);
|
| #endif
|
| #if defined(PNG_READ_iTXt_SUPPORTED)
|
| - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
|
| + else if (!png_memcmp(chunk_name, png_iTXt, 4))
|
| png_handle_iTXt(png_ptr, info_ptr, length);
|
| #endif
|
| else
|
| @@ -1111,9 +1089,7 @@
|
|
|
| png_debug(1, "in png_destroy_read_struct\n");
|
| if (png_ptr_ptr != NULL)
|
| - {
|
| png_ptr = *png_ptr_ptr;
|
| - }
|
| if (png_ptr == NULL)
|
| return;
|
|
|
| @@ -1159,13 +1135,16 @@
|
| *end_info_ptr_ptr = NULL;
|
| }
|
|
|
| + if (png_ptr != NULL)
|
| + {
|
| #ifdef PNG_USER_MEM_SUPPORTED
|
| - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
|
| - (png_voidp)mem_ptr);
|
| + png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
|
| + (png_voidp)mem_ptr);
|
| #else
|
| - png_destroy_struct((png_voidp)png_ptr);
|
| + png_destroy_struct((png_voidp)png_ptr);
|
| #endif
|
| - *png_ptr_ptr = NULL;
|
| + *png_ptr_ptr = NULL;
|
| + }
|
| }
|
|
|
| /* free all memory used by the read (old method) */
|
| @@ -1192,6 +1171,7 @@
|
| png_free(png_ptr, png_ptr->zbuf);
|
| png_free(png_ptr, png_ptr->big_row_buf);
|
| png_free(png_ptr, png_ptr->prev_row);
|
| + png_free(png_ptr, png_ptr->chunkdata);
|
| #if defined(PNG_READ_DITHER_SUPPORTED)
|
| png_free(png_ptr, png_ptr->palette_lookup);
|
| png_free(png_ptr, png_ptr->dither_index);
|
| @@ -1288,7 +1268,7 @@
|
| * being used again.
|
| */
|
| #ifdef PNG_SETJMP_SUPPORTED
|
| - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
|
| + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
| #endif
|
|
|
| error_fn = png_ptr->error_fn;
|
| @@ -1298,7 +1278,7 @@
|
| free_fn = png_ptr->free_fn;
|
| #endif
|
|
|
| - png_memset(png_ptr, 0, png_sizeof (png_struct));
|
| + png_memset(png_ptr, 0, png_sizeof(png_struct));
|
|
|
| png_ptr->error_fn = error_fn;
|
| png_ptr->warning_fn = warning_fn;
|
| @@ -1308,7 +1288,7 @@
|
| #endif
|
|
|
| #ifdef PNG_SETJMP_SUPPORTED
|
| - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
|
| + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
|
| #endif
|
|
|
| }
|
| @@ -1316,7 +1296,7 @@
|
| void PNGAPI
|
| png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
|
| {
|
| - if(png_ptr == NULL) return;
|
| + if (png_ptr == NULL) return;
|
| png_ptr->read_row_fn = read_row_fn;
|
| }
|
|
|
| @@ -1330,7 +1310,7 @@
|
| {
|
| int row;
|
|
|
| - if(png_ptr == NULL) return;
|
| + if (png_ptr == NULL) return;
|
| #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
| /* invert the alpha channel from opacity to transparency
|
| */
|
| @@ -1343,7 +1323,7 @@
|
| */
|
| png_read_info(png_ptr, info_ptr);
|
| if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
|
| - png_error(png_ptr,"Image is too high to process with png_read_png()");
|
| + png_error(png_ptr, "Image is too high to process with png_read_png()");
|
|
|
| /* -------------- image transformations start here ------------------- */
|
|
|
| @@ -1450,7 +1430,7 @@
|
| #ifdef PNG_FREE_ME_SUPPORTED
|
| png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
|
| #endif
|
| - if(info_ptr->row_pointers == NULL)
|
| + if (info_ptr->row_pointers == NULL)
|
| {
|
| info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
|
| info_ptr->height * png_sizeof(png_bytep));
|
|
|