updated libpng to 1.2.26

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24758 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2008-04-02 20:58:54 +00:00
parent a0a9d225d3
commit f6604eaad7
12 changed files with 260 additions and 154 deletions
+31 -13
View File
@@ -1,15 +1,15 @@
/* png.h - header file for PNG reference library /* png.h - header file for PNG reference library
* *
* libpng version 1.2.22 - October 13, 2007 * libpng version 1.2.26 - April 2, 2008
* Copyright (c) 1998-2007 Glenn Randers-Pehrson * Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* Authors and maintainers: * Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.2.22 - October 13, 2007: Glenn * libpng versions 0.97, January 1998, through 1.2.26 - April 2, 2008: Glenn
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
* *
* Note about libpng version numbers: * Note about libpng version numbers:
@@ -169,6 +169,18 @@
* 1.2.22rc1 13 10222 12.so.0.22[.0] * 1.2.22rc1 13 10222 12.so.0.22[.0]
* 1.0.30 10 10030 10.so.0.30[.0] * 1.0.30 10 10030 10.so.0.30[.0]
* 1.2.22 13 10222 12.so.0.22[.0] * 1.2.22 13 10222 12.so.0.22[.0]
* 1.2.23beta01-05 13 10223 12.so.0.23[.0]
* 1.2.23rc01 13 10223 12.so.0.23[.0]
* 1.2.23 13 10223 12.so.0.23[.0]
* 1.2.24beta01-02 13 10224 12.so.0.24[.0]
* 1.2.24rc01 13 10224 12.so.0.24[.0]
* 1.2.24 13 10224 12.so.0.24[.0]
* 1.2.25beta01-06 13 10225 12.so.0.25[.0]
* 1.2.25rc01-02 13 10225 12.so.0.25[.0]
* 1.0.31 10 10031 10.so.0.31[.0]
* 1.2.25 13 10225 12.so.0.25[.0]
* 1.2.26beta01-06 13 10226 12.so.0.26[.0]
* 1.2.26rc01 13 10226 12.so.0.26[.0]
* *
* Henceforth the source version will match the shared-library major * Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be * and minor numbers; the shared-library major version number will be
@@ -198,8 +210,8 @@
* If you modify libpng you may insert additional notices immediately following * If you modify libpng you may insert additional notices immediately following
* this sentence. * this sentence.
* *
* libpng versions 1.2.6, August 15, 2004, through 1.2.22, October 13, 2007, are * libpng versions 1.2.6, August 15, 2004, through 1.2.26, April 2, 2008, are
* Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are * Copyright (c) 2004, 2006-2008 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5 * distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors: * with the following individual added to the list of Contributing Authors:
* *
@@ -310,13 +322,13 @@
* Y2K compliance in libpng: * Y2K compliance in libpng:
* ========================= * =========================
* *
* October 13, 2007 * April 2, 2008
* *
* Since the PNG Development group is an ad-hoc body, we can't make * Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration. * an official declaration.
* *
* This is your unofficial assurance that libpng from version 0.71 and * This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.2.22 are Y2K compliant. It is my belief that earlier * upward through 1.2.26 are Y2K compliant. It is my belief that earlier
* versions were also Y2K compliant. * versions were also Y2K compliant.
* *
* Libpng only has three year fields. One is a 2-byte unsigned integer * Libpng only has three year fields. One is a 2-byte unsigned integer
@@ -372,9 +384,9 @@
*/ */
/* Version information for png.h - this should match the version in png.c */ /* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.2.22" #define PNG_LIBPNG_VER_STRING "1.2.26"
#define PNG_HEADER_VERSION_STRING \ #define PNG_HEADER_VERSION_STRING \
" libpng version 1.2.22 - October 13, 2007\n" " libpng version 1.2.26 - April 2, 2008\n"
#define PNG_LIBPNG_VER_SONUM 0 #define PNG_LIBPNG_VER_SONUM 0
#define PNG_LIBPNG_VER_DLLNUM 13 #define PNG_LIBPNG_VER_DLLNUM 13
@@ -382,7 +394,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 2 #define PNG_LIBPNG_VER_MINOR 2
#define PNG_LIBPNG_VER_RELEASE 22 #define PNG_LIBPNG_VER_RELEASE 26
/* This should match the numeric part of the final component of /* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */ * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
@@ -410,7 +422,7 @@
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
* version 1.0.0 was mis-numbered 100 instead of 10000). From * version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */
#define PNG_LIBPNG_VER 10222 /* 1.2.22 */ #define PNG_LIBPNG_VER 10226 /* 1.2.26 */
#ifndef PNG_VERSION_INFO_ONLY #ifndef PNG_VERSION_INFO_ONLY
/* include the compression library's header */ /* include the compression library's header */
@@ -651,9 +663,10 @@ typedef png_time FAR * FAR * png_timepp;
* up private chunks for output even though the library doesn't actually * up private chunks for output even though the library doesn't actually
* know about their semantics. * know about their semantics.
*/ */
#define PNG_CHUNK_NAME_LENGTH 5
typedef struct png_unknown_chunk_t typedef struct png_unknown_chunk_t
{ {
png_byte name[5]; png_byte name[PNG_CHUNK_NAME_LENGTH];
png_byte *data; png_byte *data;
png_size_t size; png_size_t size;
@@ -1180,10 +1193,12 @@ struct png_struct_def
png_uint_32 row_number; /* current row in interlace pass */ png_uint_32 row_number; /* current row in interlace pass */
png_bytep prev_row; /* buffer to save previous (unfiltered) row */ png_bytep prev_row; /* buffer to save previous (unfiltered) row */
png_bytep row_buf; /* buffer to save current (unfiltered) row */ png_bytep row_buf; /* buffer to save current (unfiltered) row */
#ifndef PNG_NO_WRITE_FILTERING
png_bytep sub_row; /* buffer to save "sub" row when filtering */ png_bytep sub_row; /* buffer to save "sub" row when filtering */
png_bytep up_row; /* buffer to save "up" row when filtering */ png_bytep up_row; /* buffer to save "up" row when filtering */
png_bytep avg_row; /* buffer to save "avg" row when filtering */ png_bytep avg_row; /* buffer to save "avg" row when filtering */
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
#endif
png_row_info row_info; /* used for transformation routines */ png_row_info row_info; /* used for transformation routines */
png_uint_32 idat_size; /* current IDAT size for read */ png_uint_32 idat_size; /* current IDAT size for read */
@@ -1415,13 +1430,16 @@ struct png_struct_def
/* storage for unknown chunk that the library doesn't recognize. */ /* storage for unknown chunk that the library doesn't recognize. */
png_unknown_chunk unknown_chunk; png_unknown_chunk unknown_chunk;
#endif #endif
/* New members added in libpng-1.2.26 */
png_uint_32 old_big_row_buf_size, old_prev_row_size;
}; };
/* This triggers a compiler error in png.c, if png.c and png.h /* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number. * do not agree upon the version number.
*/ */
typedef png_structp version_1_2_22; typedef png_structp version_1_2_26;
typedef png_struct FAR * FAR * png_structpp; typedef png_struct FAR * FAR * png_structpp;
+6 -8
View File
@@ -1,9 +1,9 @@
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine configurable file for libpng
* *
* libpng version 1.2.22 - October 13, 2007 * libpng version 1.2.26 - April 2, 2008
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson * Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
@@ -323,7 +323,7 @@
/* If you encounter a compiler error here, see the explanation /* If you encounter a compiler error here, see the explanation
* near the end of INSTALL. * near the end of INSTALL.
*/ */
__png.h__ already includes setjmp.h; __pngconf.h__ already includes setjmp.h;
__dont__ include it again.; __dont__ include it again.;
# endif # endif
# endif /* __linux__ */ # endif /* __linux__ */
@@ -333,7 +333,9 @@
# ifdef __linux__ # ifdef __linux__
# ifdef PNG_SAVE_BSD_SOURCE # ifdef PNG_SAVE_BSD_SOURCE
# define _BSD_SOURCE # ifndef _BSD_SOURCE
# define _BSD_SOURCE
# endif
# undef PNG_SAVE_BSD_SOURCE # undef PNG_SAVE_BSD_SOURCE
# endif # endif
# endif /* __linux__ */ # endif /* __linux__ */
@@ -1430,8 +1432,6 @@ typedef z_stream FAR * png_zstreamp;
# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) # define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) # define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
# define png_snprintf _fsnprintf /* Added to v 1.2.19 */ # define png_snprintf _fsnprintf /* Added to v 1.2.19 */
# define png_strcpy _fstrcpy
# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
# define png_strlen _fstrlen # define png_strlen _fstrlen
# define png_memcmp _fmemcmp /* SJT: added */ # define png_memcmp _fmemcmp /* SJT: added */
# define png_memcpy _fmemcpy # define png_memcpy _fmemcpy
@@ -1460,8 +1460,6 @@ typedef z_stream FAR * png_zstreamp;
# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \ # define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
sprintf(s1,fmt,x1,x2,x3,x4,x5,x6) sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
# endif # endif
# define png_strcpy strcpy
# define png_strncpy strncpy /* Added to v 1.2.6 */
# define png_strlen strlen # define png_strlen strlen
# define png_memcmp memcmp /* SJT: added */ # define png_memcmp memcmp /* SJT: added */
# define png_memcpy memcpy # define png_memcpy memcpy
+3 -3
View File
@@ -13,7 +13,7 @@
#include "png.h" #include "png.h"
/* Generate a compiler error if there is an old png.h in the search path. */ /* Generate a compiler error if there is an old png.h in the search path. */
typedef version_1_2_22 Your_png_h_is_not_version_1_2_22; typedef version_1_2_26 Your_png_h_is_not_version_1_2_26;
/* Version information for C files. This had better match the version /* Version information for C files. This had better match the version
* string defined in png.h. */ * string defined in png.h. */
@@ -693,8 +693,8 @@ png_charp PNGAPI
png_get_copyright(png_structp png_ptr) png_get_copyright(png_structp png_ptr)
{ {
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
return ((png_charp) "\n libpng version 1.2.22 - October 13, 2007\n\ return ((png_charp) "\n libpng version 1.2.26 - April 2, 2008\n\
Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\ Copyright (c) 1998-2008 Glenn Randers-Pehrson\n\
Copyright (c) 1996-1997 Andreas Dilger\n\ Copyright (c) 1996-1997 Andreas Dilger\n\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
} }
+6 -4
View File
@@ -136,6 +136,8 @@ static PNG_CONST char png_digit[16] = {
'A', 'B', 'C', 'D', 'E', 'F' 'A', 'B', 'C', 'D', 'E', 'F'
}; };
#define PNG_MAX_ERROR_TEXT 64
#if !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) #if !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT)
static void /* PRIVATE */ static void /* PRIVATE */
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
@@ -165,8 +167,8 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
{ {
buffer[iout++] = ':'; buffer[iout++] = ':';
buffer[iout++] = ' '; buffer[iout++] = ' ';
png_strncpy(buffer+iout, error_message, 63); png_memcpy(buffer+iout, error_message, PNG_MAX_ERROR_TEXT);
buffer[iout+63] = '\0'; buffer[iout+PNG_MAX_ERROR_TEXT-1] = '\0';
} }
} }
@@ -174,7 +176,7 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
void PNGAPI void PNGAPI
png_chunk_error(png_structp png_ptr, png_const_charp error_message) png_chunk_error(png_structp png_ptr, png_const_charp error_message)
{ {
char msg[18+64]; char msg[18+PNG_MAX_ERROR_TEXT];
if (png_ptr == NULL) if (png_ptr == NULL)
png_error(png_ptr, error_message); png_error(png_ptr, error_message);
else else
@@ -190,7 +192,7 @@ png_chunk_error(png_structp png_ptr, png_const_charp error_message)
void PNGAPI void PNGAPI
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
{ {
char msg[18+64]; char msg[18+PNG_MAX_ERROR_TEXT];
if (png_ptr == NULL) if (png_ptr == NULL)
png_warning(png_ptr, warning_message); png_warning(png_ptr, warning_message);
else else
+3 -3
View File
@@ -1,9 +1,9 @@
/* pngmem.c - stub functions for memory allocation /* pngmem.c - stub functions for memory allocation
* *
* Last changed in libpng 1.2.13 November 13, 2006 * Last changed in libpng 1.2.26 [April 2, 2008]
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson * Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -456,7 +456,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
if (size > (png_uint_32)65536L) if (size > (png_uint_32)65536L)
{ {
#ifndef PNG_USER_MEM_SUPPORTED #ifndef PNG_USER_MEM_SUPPORTED
if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Cannot Allocate > 64K"); png_error(png_ptr, "Cannot Allocate > 64K");
else else
#endif #endif
+39 -30
View File
@@ -1,9 +1,9 @@
/* pngpread.c - read a png file in push mode /* pngpread.c - read a png file in push mode
* *
* Last changed in libpng 1.2.22 [October 13, 2007] * Last changed in libpng 1.2.26 [April 2, 2008]
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson * Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
@@ -28,7 +28,7 @@ void PNGAPI
png_process_data(png_structp png_ptr, png_infop info_ptr, png_process_data(png_structp png_ptr, png_infop info_ptr,
png_bytep buffer, png_size_t buffer_size) png_bytep buffer, png_size_t buffer_size)
{ {
if(png_ptr == NULL) return; if(png_ptr == NULL || info_ptr == NULL) return;
png_push_restore_buffer(png_ptr, buffer, buffer_size); png_push_restore_buffer(png_ptr, buffer, buffer_size);
while (png_ptr->buffer_size) while (png_ptr->buffer_size)
@@ -224,6 +224,8 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{ {
if (png_ptr->push_length != 13)
png_error(png_ptr, "Invalid IHDR length");
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
@@ -1018,32 +1020,37 @@ png_read_push_finish_row(png_structp png_ptr)
png_ptr->rowbytes + 1); png_ptr->rowbytes + 1);
do do
{ {
png_ptr->pass++; int pass;
if ((png_ptr->pass == 1 && png_ptr->width < 5) || pass = png_ptr->pass;
(png_ptr->pass == 3 && png_ptr->width < 3) || pass++;
(png_ptr->pass == 5 && png_ptr->width < 2)) if ((pass == 1 && png_ptr->width < 5) ||
png_ptr->pass++; (pass == 3 && png_ptr->width < 3) ||
(pass == 5 && png_ptr->width < 2))
pass++;
if (png_ptr->pass > 7) if (pass > 7)
png_ptr->pass--; pass--;
if (png_ptr->pass >= 7) png_ptr->pass = (png_byte) pass;
break; if (pass < 7)
{
png_ptr->iwidth = (png_ptr->width +
png_pass_inc[pass] - 1 -
png_pass_start[pass]) /
png_pass_inc[pass];
png_ptr->iwidth = (png_ptr->width + png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,
png_pass_inc[png_ptr->pass] - 1 - png_ptr->iwidth) + 1;
png_pass_start[png_ptr->pass]) /
png_pass_inc[png_ptr->pass];
png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, if (png_ptr->transformations & PNG_INTERLACE)
png_ptr->iwidth) + 1; break;
if (png_ptr->transformations & PNG_INTERLACE) png_ptr->num_rows = (png_ptr->height +
break; png_pass_yinc[pass] - 1 -
png_pass_ystart[pass]) /
png_ptr->num_rows = (png_ptr->height + png_pass_yinc[pass];
png_pass_yinc[png_ptr->pass] - 1 - }
png_pass_ystart[png_ptr->pass]) / else
png_pass_yinc[png_ptr->pass]; break;
} while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
} }
@@ -1490,9 +1497,11 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
length = (png_uint_32)65535L; length = (png_uint_32)65535L;
} }
#endif #endif
png_strncpy((png_charp)png_ptr->unknown_chunk.name, png_memcpy((png_charp)png_ptr->unknown_chunk.name,
(png_charp)png_ptr->chunk_name, 4); (png_charp)png_ptr->chunk_name,
png_ptr->unknown_chunk.name[4] = '\0'; png_sizeof(png_ptr->unknown_chunk.name));
png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1]='\0';
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length); png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_ptr->unknown_chunk.size = (png_size_t)length; png_ptr->unknown_chunk.size = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
@@ -1515,9 +1524,9 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
&png_ptr->unknown_chunk, 1); &png_ptr->unknown_chunk, 1);
} }
} }
#else else
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
#endif #endif
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
png_free(png_ptr, png_ptr->unknown_chunk.data); png_free(png_ptr, png_ptr->unknown_chunk.data);
png_ptr->unknown_chunk.data = NULL; png_ptr->unknown_chunk.data = NULL;
} }
+28 -21
View File
@@ -1,9 +1,9 @@
/* pngread.c - read a PNG file /* pngread.c - read a PNG file
* *
* Last changed in libpng 1.2.20 September 7, 2007 * Last changed in libpng 1.2.25 [February 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson * Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -89,12 +89,18 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
i=0; if(user_png_ver)
do
{ {
if(user_png_ver[i] != png_libpng_ver[i]) i=0;
do
{
if(user_png_ver[i] != png_libpng_ver[i])
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
} while (png_libpng_ver[i++]);
}
else
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
} while (png_libpng_ver[i++]);
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
{ {
@@ -318,7 +324,7 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
void PNGAPI void PNGAPI
png_read_info(png_structp png_ptr, png_infop info_ptr) png_read_info(png_structp png_ptr, png_infop info_ptr)
{ {
if(png_ptr == NULL) return; if(png_ptr == NULL || info_ptr == NULL) return;
png_debug(1, "in png_read_info\n"); png_debug(1, "in png_read_info\n");
/* If we haven't checked all of the PNG signature bytes, do so now. */ /* If we haven't checked all of the PNG signature bytes, do so now. */
if (png_ptr->sig_bytes < 8) if (png_ptr->sig_bytes < 8)
@@ -1099,13 +1105,22 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
png_structp png_ptr = NULL; png_structp png_ptr = NULL;
png_infop info_ptr = NULL, end_info_ptr = NULL; png_infop info_ptr = NULL, end_info_ptr = NULL;
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn; png_free_ptr free_fn = NULL;
png_voidp mem_ptr; png_voidp mem_ptr = NULL;
#endif #endif
png_debug(1, "in png_destroy_read_struct\n"); png_debug(1, "in png_destroy_read_struct\n");
if (png_ptr_ptr != NULL) if (png_ptr_ptr != NULL)
{
png_ptr = *png_ptr_ptr; png_ptr = *png_ptr_ptr;
}
if (png_ptr == NULL)
return;
#ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn;
mem_ptr = png_ptr->mem_ptr;
#endif
if (info_ptr_ptr != NULL) if (info_ptr_ptr != NULL)
info_ptr = *info_ptr_ptr; info_ptr = *info_ptr_ptr;
@@ -1113,11 +1128,6 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
if (end_info_ptr_ptr != NULL) if (end_info_ptr_ptr != NULL)
end_info_ptr = *end_info_ptr_ptr; end_info_ptr = *end_info_ptr_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn;
mem_ptr = png_ptr->mem_ptr;
#endif
png_read_destroy(png_ptr, info_ptr, end_info_ptr); png_read_destroy(png_ptr, info_ptr, end_info_ptr);
if (info_ptr != NULL) if (info_ptr != NULL)
@@ -1149,16 +1159,13 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
*end_info_ptr_ptr = NULL; *end_info_ptr_ptr = NULL;
} }
if (png_ptr != NULL)
{
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr); (png_voidp)mem_ptr);
#else #else
png_destroy_struct((png_voidp)png_ptr); png_destroy_struct((png_voidp)png_ptr);
#endif #endif
*png_ptr_ptr = NULL; *png_ptr_ptr = NULL;
}
} }
/* free all memory used by the read (old method) */ /* free all memory used by the read (old method) */
+17 -2
View File
@@ -1,9 +1,9 @@
/* pngrtran.c - transforms the data in a row for PNG readers /* pngrtran.c - transforms the data in a row for PNG readers
* *
* Last changed in libpng 1.2.22 [October 13, 2007] * Last changed in libpng 1.2.25 [February 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson * Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -964,6 +964,14 @@ png_init_read_transformations(png_structp png_ptr)
palette[i].blue = png_ptr->gamma_table[palette[i].blue]; palette[i].blue = png_ptr->gamma_table[palette[i].blue];
} }
} }
/* Prevent the transformations being done again, and make sure
* that the now spurious alpha channel is stripped - the code
* has just reduced background composition and gamma correction
* to a simply alpha channel strip.
*/
png_ptr->transformations &= ~PNG_BACKGROUND;
png_ptr->transformations &= ~PNG_GAMMA;
png_ptr->transformations |= PNG_STRIP_ALPHA;
} }
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
else else
@@ -1038,6 +1046,9 @@ png_init_read_transformations(png_structp png_ptr)
palette[i].green = png_ptr->gamma_table[palette[i].green]; palette[i].green = png_ptr->gamma_table[palette[i].green];
palette[i].blue = png_ptr->gamma_table[palette[i].blue]; palette[i].blue = png_ptr->gamma_table[palette[i].blue];
} }
/* Done the gamma correction. */
png_ptr->transformations &= ~PNG_GAMMA;
} }
} }
#if defined(PNG_READ_BACKGROUND_SUPPORTED) #if defined(PNG_READ_BACKGROUND_SUPPORTED)
@@ -1075,6 +1086,10 @@ png_init_read_transformations(png_structp png_ptr)
png_ptr->trans[i], back.blue); png_ptr->trans[i], back.blue);
} }
} }
/* Handled alpha, still need to strip the channel. */
png_ptr->transformations &= ~PNG_BACKGROUND;
png_ptr->transformations |= PNG_STRIP_ALPHA;
} }
#endif /* PNG_READ_BACKGROUND_SUPPORTED */ #endif /* PNG_READ_BACKGROUND_SUPPORTED */
+37 -14
View File
@@ -1,9 +1,9 @@
/* pngrutil.c - utilities to read a PNG file /* pngrutil.c - utilities to read a PNG file
* *
* Last changed in libpng 1.2.22 [October 13, 2007] * Last changed in libpng 1.2.26 [April 2, 2008]
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson * Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -230,7 +230,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); text_size = (png_size_t)(chunklength - (text - chunkdata) - 1);
text_size = png_sizeof(msg) > text_size ? text_size : text_size = png_sizeof(msg) > text_size ? text_size :
png_sizeof(msg); png_sizeof(msg);
png_memcpy(text + prefix_size, msg, text_size + 1); png_memcpy(text + prefix_size, msg, text_size);
break; break;
} }
if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END)
@@ -1393,7 +1393,7 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{ {
png_ptr->background.index = buf[0]; png_ptr->background.index = buf[0];
if(info_ptr->num_palette) if (info_ptr && info_ptr->num_palette)
{ {
if(buf[0] > info_ptr->num_palette) if(buf[0] > info_ptr->num_palette)
{ {
@@ -1792,7 +1792,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#else #else
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
if (swidth == NULL) if (sheight == NULL)
{ {
png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
return; return;
@@ -2223,9 +2223,10 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
length = (png_uint_32)65535L; length = (png_uint_32)65535L;
} }
#endif #endif
png_strncpy((png_charp)png_ptr->unknown_chunk.name, png_memcpy((png_charp)png_ptr->unknown_chunk.name,
(png_charp)png_ptr->chunk_name, 4); (png_charp)png_ptr->chunk_name,
png_ptr->unknown_chunk.name[4] = '\0'; png_sizeof(png_ptr->unknown_chunk.name));
png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1] = '\0';
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length); png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_ptr->unknown_chunk.size = (png_size_t)length; png_ptr->unknown_chunk.size = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
@@ -2248,9 +2249,9 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
&png_ptr->unknown_chunk, 1); &png_ptr->unknown_chunk, 1);
} }
} }
#else else
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
#endif #endif
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
png_free(png_ptr, png_ptr->unknown_chunk.data); png_free(png_ptr, png_ptr->unknown_chunk.data);
png_ptr->unknown_chunk.data = NULL; png_ptr->unknown_chunk.data = NULL;
} }
@@ -2850,6 +2851,7 @@ void /* PRIVATE */
png_read_finish_row(png_structp png_ptr) png_read_finish_row(png_structp png_ptr)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* start of interlace block */ /* start of interlace block */
@@ -2863,6 +2865,7 @@ png_read_finish_row(png_structp png_ptr)
/* offset to next interlace block in the y direction */ /* offset to next interlace block in the y direction */
PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif /* PNG_READ_INTERLACING_SUPPORTED */
#endif #endif
png_debug(1, "in png_read_finish_row\n"); png_debug(1, "in png_read_finish_row\n");
@@ -2870,6 +2873,7 @@ png_read_finish_row(png_structp png_ptr)
if (png_ptr->row_number < png_ptr->num_rows) if (png_ptr->row_number < png_ptr->num_rows)
return; return;
#ifdef PNG_READ_INTERLACING_SUPPORTED
if (png_ptr->interlaced) if (png_ptr->interlaced)
{ {
png_ptr->row_number = 0; png_ptr->row_number = 0;
@@ -2904,6 +2908,7 @@ png_read_finish_row(png_structp png_ptr)
if (png_ptr->pass < 7) if (png_ptr->pass < 7)
return; return;
} }
#endif /* PNG_READ_INTERLACING_SUPPORTED */
if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
{ {
@@ -2978,6 +2983,7 @@ void /* PRIVATE */
png_read_start_row(png_structp png_ptr) png_read_start_row(png_structp png_ptr)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* start of interlace block */ /* start of interlace block */
@@ -2991,6 +2997,7 @@ png_read_start_row(png_structp png_ptr)
/* offset to next interlace block in the y direction */ /* offset to next interlace block in the y direction */
PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
#endif #endif
int max_pixel_depth; int max_pixel_depth;
@@ -2999,6 +3006,7 @@ png_read_start_row(png_structp png_ptr)
png_debug(1, "in png_read_start_row\n"); png_debug(1, "in png_read_start_row\n");
png_ptr->zstream.avail_in = 0; png_ptr->zstream.avail_in = 0;
png_init_read_transformations(png_ptr); png_init_read_transformations(png_ptr);
#ifdef PNG_READ_INTERLACING_SUPPORTED
if (png_ptr->interlaced) if (png_ptr->interlaced)
{ {
if (!(png_ptr->transformations & PNG_INTERLACE)) if (!(png_ptr->transformations & PNG_INTERLACE))
@@ -3019,6 +3027,7 @@ png_read_start_row(png_structp png_ptr)
png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); png_error(png_ptr, "Rowbytes overflow in png_read_start_row");
} }
else else
#endif /* PNG_READ_INTERLACING_SUPPORTED */
{ {
png_ptr->num_rows = png_ptr->height; png_ptr->num_rows = png_ptr->height;
png_ptr->iwidth = png_ptr->width; png_ptr->iwidth = png_ptr->width;
@@ -3137,8 +3146,15 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
if (row_bytes > (png_uint_32)65536L) if (row_bytes > (png_uint_32)65536L)
png_error(png_ptr, "This image requires a row greater than 64KB"); png_error(png_ptr, "This image requires a row greater than 64KB");
#endif #endif
png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
png_ptr->row_buf = png_ptr->big_row_buf+32; if(row_bytes + 64 > png_ptr->old_big_row_buf_size)
{
if (png_ptr->big_row_buf)
png_free(png_ptr,png_ptr->big_row_buf);
png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
png_ptr->row_buf = png_ptr->big_row_buf+32;
png_ptr->old_big_row_buf_size = row_bytes+64;
}
#ifdef PNG_MAX_MALLOC_64K #ifdef PNG_MAX_MALLOC_64K
if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)
@@ -3146,8 +3162,15 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
#endif #endif
if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1)) if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1))
png_error(png_ptr, "Row has too many bytes to allocate in memory."); png_error(png_ptr, "Row has too many bytes to allocate in memory.");
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
png_ptr->rowbytes + 1)); if(png_ptr->rowbytes+1 > png_ptr->old_prev_row_size)
{
if (png_ptr->prev_row)
png_free(png_ptr,png_ptr->prev_row);
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
png_ptr->rowbytes + 1));
png_ptr->old_prev_row_size = png_ptr->rowbytes+1;
}
png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
+43 -36
View File
@@ -1,9 +1,9 @@
/* pngset.c - storage of image information into info struct /* pngset.c - storage of image information into info struct
* *
* Last changed in libpng 1.2.22 [October 13, 2007] * Last changed in libpng 1.2.25 [February 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson * Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -41,7 +41,13 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
png_debug1(1, "in %s storage function\n", "cHRM"); png_debug1(1, "in %s storage function\n", "cHRM");
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
if (!(white_x || white_y || red_x || red_y || green_x || green_y ||
blue_x || blue_y))
{
png_warning(png_ptr,
"Ignoring attempt to set all-zero chromaticity values");
return;
}
if (white_x < 0.0 || white_y < 0.0 || if (white_x < 0.0 || white_y < 0.0 ||
red_x < 0.0 || red_y < 0.0 || red_x < 0.0 || red_y < 0.0 ||
green_x < 0.0 || green_y < 0.0 || green_x < 0.0 || green_y < 0.0 ||
@@ -93,6 +99,13 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
if (!(white_x || white_y || red_x || red_y || green_x || green_y ||
blue_x || blue_y))
{
png_warning(png_ptr,
"Ignoring attempt to set all-zero chromaticity values");
return;
}
if (white_x < 0 || white_y < 0 || if (white_x < 0 || white_y < 0 ||
red_x < 0 || red_y < 0 || red_x < 0 || red_y < 0 ||
green_x < 0 || green_y < 0 || green_x < 0 || green_y < 0 ||
@@ -102,25 +115,14 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
"Ignoring attempt to set negative chromaticity value"); "Ignoring attempt to set negative chromaticity value");
return; return;
} }
#ifdef PNG_FLOATING_POINT_SUPPORTED if (white_x > (png_fixed_point) PNG_UINT_31_MAX ||
if (white_x > (double) PNG_UINT_31_MAX || white_y > (png_fixed_point) PNG_UINT_31_MAX ||
white_y > (double) PNG_UINT_31_MAX || red_x > (png_fixed_point) PNG_UINT_31_MAX ||
red_x > (double) PNG_UINT_31_MAX || red_y > (png_fixed_point) PNG_UINT_31_MAX ||
red_y > (double) PNG_UINT_31_MAX || green_x > (png_fixed_point) PNG_UINT_31_MAX ||
green_x > (double) PNG_UINT_31_MAX || green_y > (png_fixed_point) PNG_UINT_31_MAX ||
green_y > (double) PNG_UINT_31_MAX || blue_x > (png_fixed_point) PNG_UINT_31_MAX ||
blue_x > (double) PNG_UINT_31_MAX || blue_y > (png_fixed_point) PNG_UINT_31_MAX )
blue_y > (double) PNG_UINT_31_MAX)
#else
if (white_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
white_y > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
red_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
red_y > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
green_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
green_y > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
blue_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
blue_y > (png_fixed_point) PNG_UINT_31_MAX/100000L)
#endif
{ {
png_warning(png_ptr, png_warning(png_ptr,
"Ignoring attempt to set chromaticity value exceeding 21474.83"); "Ignoring attempt to set chromaticity value exceeding 21474.83");
@@ -486,6 +488,7 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
{ {
png_warning(png_ptr, png_warning(png_ptr,
"Memory allocation failed while processing sCAL."); "Memory allocation failed while processing sCAL.");
return;
} }
png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
@@ -497,9 +500,9 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
png_free (png_ptr, info_ptr->scal_s_width); png_free (png_ptr, info_ptr->scal_s_width);
png_warning(png_ptr, png_warning(png_ptr,
"Memory allocation failed while processing sCAL."); "Memory allocation failed while processing sCAL.");
return;
} }
png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
info_ptr->valid |= PNG_INFO_sCAL; info_ptr->valid |= PNG_INFO_sCAL;
#ifdef PNG_FREE_ME_SUPPORTED #ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_SCAL; info_ptr->free_me |= PNG_FREE_SCAL;
@@ -679,19 +682,20 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
{ {
png_charp new_iccp_name; png_charp new_iccp_name;
png_charp new_iccp_profile; png_charp new_iccp_profile;
png_uint_32 length;
png_debug1(1, "in %s storage function\n", "iCCP"); png_debug1(1, "in %s storage function\n", "iCCP");
if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
return; return;
new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1); length = png_strlen(name)+1;
new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length);
if (new_iccp_name == NULL) if (new_iccp_name == NULL)
{ {
png_warning(png_ptr, "Insufficient memory to process iCCP chunk."); png_warning(png_ptr, "Insufficient memory to process iCCP chunk.");
return; return;
} }
png_strncpy(new_iccp_name, name, png_strlen(name)); png_memcpy(new_iccp_name, name, length);
new_iccp_name[png_strlen(name)] = '\0';
new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen); new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen);
if (new_iccp_profile == NULL) if (new_iccp_profile == NULL)
{ {
@@ -972,29 +976,29 @@ png_set_sPLT(png_structp png_ptr,
{ {
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
png_sPLT_tp from = entries + i; png_sPLT_tp from = entries + i;
png_uint_32 length;
to->name = (png_charp)png_malloc_warn(png_ptr, length = png_strlen(from->name) + 1;
png_strlen(from->name) + 1); to->name = (png_charp)png_malloc_warn(png_ptr, length);
if (to->name == NULL) if (to->name == NULL)
{ {
png_warning(png_ptr, png_warning(png_ptr,
"Out of memory while processing sPLT chunk"); "Out of memory while processing sPLT chunk");
continue;
} }
/* TODO: use png_malloc_warn */ png_memcpy(to->name, from->name, length);
png_strncpy(to->name, from->name, png_strlen(from->name));
to->name[png_strlen(from->name)] = '\0';
to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
from->nentries * png_sizeof(png_sPLT_entry)); from->nentries * png_sizeof(png_sPLT_entry));
/* TODO: use png_malloc_warn */
png_memcpy(to->entries, from->entries,
from->nentries * png_sizeof(png_sPLT_entry));
if (to->entries == NULL) if (to->entries == NULL)
{ {
png_warning(png_ptr, png_warning(png_ptr,
"Out of memory while processing sPLT chunk"); "Out of memory while processing sPLT chunk");
png_free(png_ptr,to->name); png_free(png_ptr,to->name);
to->name = NULL; to->name = NULL;
continue;
} }
png_memcpy(to->entries, from->entries,
from->nentries * png_sizeof(png_sPLT_entry));
to->nentries = from->nentries; to->nentries = from->nentries;
to->depth = from->depth; to->depth = from->depth;
} }
@@ -1039,8 +1043,11 @@ png_set_unknown_chunks(png_structp png_ptr,
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
png_unknown_chunkp from = unknowns + i; png_unknown_chunkp from = unknowns + i;
png_strncpy((png_charp)to->name, (png_charp)from->name, 4); png_memcpy((png_charp)to->name,
to->name[4] = '\0'; (png_charp)from->name,
png_sizeof(from->name));
to->name[png_sizeof(to->name)-1] = '\0';
to->data = (png_bytep)png_malloc_warn(png_ptr, from->size); to->data = (png_bytep)png_malloc_warn(png_ptr, from->size);
if (to->data == NULL) if (to->data == NULL)
{ {
+30 -14
View File
@@ -1,9 +1,9 @@
/* pngwrite.c - general routines to write a PNG file /* pngwrite.c - general routines to write a PNG file
* *
* Last changed in libpng 1.2.15 January 5, 2007 * Last changed in libpng 1.2.25 [February 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson * Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
@@ -482,12 +482,15 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
i=0; if(user_png_ver)
do
{ {
if(user_png_ver[i] != png_libpng_ver[i]) i=0;
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; do
} while (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++]);
}
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
{ {
@@ -1000,21 +1003,32 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
#endif #endif
} }
#ifdef PNG_USER_MEM_SUPPORTED
if (png_ptr != NULL)
{
free_fn = png_ptr->free_fn;
mem_ptr = png_ptr->mem_ptr;
}
#endif
if (info_ptr_ptr != NULL) if (info_ptr_ptr != NULL)
info_ptr = *info_ptr_ptr; info_ptr = *info_ptr_ptr;
if (info_ptr != NULL) if (info_ptr != NULL)
{ {
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); if (png_ptr != NULL)
{
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
if (png_ptr->num_chunk_list) if (png_ptr->num_chunk_list)
{ {
png_free(png_ptr, png_ptr->chunk_list); png_free(png_ptr, png_ptr->chunk_list);
png_ptr->chunk_list=NULL; png_ptr->chunk_list=NULL;
png_ptr->num_chunk_list=0; png_ptr->num_chunk_list=0;
} }
#endif #endif
}
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,
@@ -1060,11 +1074,13 @@ png_write_destroy(png_structp png_ptr)
/* free our memory. png_free checks NULL for us. */ /* free our memory. png_free checks NULL for us. */
png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->zbuf);
png_free(png_ptr, png_ptr->row_buf); png_free(png_ptr, png_ptr->row_buf);
#ifndef PNG_NO_WRITE_FILTERING
png_free(png_ptr, png_ptr->prev_row); png_free(png_ptr, png_ptr->prev_row);
png_free(png_ptr, png_ptr->sub_row); png_free(png_ptr, png_ptr->sub_row);
png_free(png_ptr, png_ptr->up_row); png_free(png_ptr, png_ptr->up_row);
png_free(png_ptr, png_ptr->avg_row); png_free(png_ptr, png_ptr->avg_row);
png_free(png_ptr, png_ptr->paeth_row); png_free(png_ptr, png_ptr->paeth_row);
#endif
#if defined(PNG_TIME_RFC1123_SUPPORTED) #if defined(PNG_TIME_RFC1123_SUPPORTED)
png_free(png_ptr, png_ptr->time_buffer); png_free(png_ptr, png_ptr->time_buffer);
+17 -6
View File
@@ -1,9 +1,9 @@
/* pngwutil.c - utilities to write a PNG file /* pngwutil.c - utilities to write a PNG file
* *
* Last changed in libpng 1.2.20 Septhember 3, 2007 * Last changed in libpng 1.2.26 [April 2, 2008]
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson * Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
@@ -380,6 +380,8 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
PNG_IHDR; PNG_IHDR;
#endif #endif
int ret;
png_byte buf[13]; /* buffer to store the IHDR info */ png_byte buf[13]; /* buffer to store the IHDR info */
png_debug(1, "in png_write_IHDR\n"); png_debug(1, "in png_write_IHDR\n");
@@ -523,10 +525,19 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_ptr->zlib_window_bits = 15; png_ptr->zlib_window_bits = 15;
if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD)) if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD))
png_ptr->zlib_method = 8; png_ptr->zlib_method = 8;
if (deflateInit2(&png_ptr->zstream, png_ptr->zlib_level, ret = deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
png_ptr->zlib_method, png_ptr->zlib_window_bits, png_ptr->zlib_method, png_ptr->zlib_window_bits,
png_ptr->zlib_mem_level, png_ptr->zlib_strategy) != Z_OK) png_ptr->zlib_mem_level, png_ptr->zlib_strategy);
png_error(png_ptr, "zlib failed to initialize compressor"); if (ret != Z_OK)
{
if (ret == Z_VERSION_ERROR) png_error(png_ptr,
"zlib failed to initialize compressor -- version error");
if (ret == Z_STREAM_ERROR) png_error(png_ptr,
"zlib failed to initialize compressor -- stream error");
if (ret == Z_MEM_ERROR) png_error(png_ptr,
"zlib failed to initialize compressor -- mem error");
png_error(png_ptr, "zlib failed to initialize compressor");
}
png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
/* libpng is not interested in zstream.data_type */ /* libpng is not interested in zstream.data_type */