diff -ru4NwbB libpng-1.2.35/contrib/pngminim/decoder/pngusr.h libpng-1.2.36beta04/contrib/pngminim/decoder/pngusr.h --- libpng-1.2.35/contrib/pngminim/decoder/pngusr.h 2007-08-19 22:30:16.000000000 -0500 +++ libpng-1.2.36beta04/contrib/pngminim/decoder/pngusr.h 2009-03-24 11:47:00.236362000 -0500 @@ -6,8 +6,12 @@ #ifndef MINRDPNGCONF_H #define MINRDPNGCONF_H +#ifdef NJET + /* No 16-bit support beyond reading with strip_16 */ +#endif + #define PNG_NO_GLOBAL_ARRAYS #define PNG_NO_WARNINGS #define png_warning(s1,s2) "" diff -ru4NwbB libpng-1.2.35/contrib/pngminim/encoder/pngusr.h libpng-1.2.36beta04/contrib/pngminim/encoder/pngusr.h --- libpng-1.2.35/contrib/pngminim/encoder/pngusr.h 2007-08-27 23:31:31.000000000 -0500 +++ libpng-1.2.36beta04/contrib/pngminim/encoder/pngusr.h 2009-03-20 08:13:44.702495000 -0500 @@ -50,8 +50,9 @@ #define PNG_NO_WRITE_OPT_PLTE #define PNG_NO_WRITE_FILTER #define PNG_NO_WRITE_WEIGHTED_FILTER #define PNG_NO_WRITE_INTERLACING_SUPPORTED +#define PNG_NO_WRITE_FLUSH #define PNG_NO_INFO_IMAGE #define PNG_NO_USER_MEM #define PNG_NO_FIXED_POINT_SUPPORTED diff -ru4NwbB libpng-1.2.35/example.c libpng-1.2.36beta04/example.c --- libpng-1.2.35/example.c 2009-02-14 15:59:26.552153830 -0600 +++ libpng-1.2.36beta04/example.c 2009-04-06 19:29:16.107708271 -0500 @@ -1,9 +1,9 @@ #if 0 /* in case someone actually tries to compile this */ /* example.c - an example of using libpng - * Last changed in libpng 1.2.35 [April 7, 2009] + * Last changed in libpng 1.2.36 [April 7, 2009] * This file has been placed in the public domain by the authors. * Maintained 1998-2009 Glenn Randers-Pehrson * Maintained 1996, 1997 Andreas Dilger) * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -598,9 +598,9 @@ * error handling functions in the png_create_write_struct() call. */ if (setjmp(png_jmpbuf(png_ptr))) { - /* If we get here, we had a problem reading the file */ + /* If we get here, we had a problem writing the file */ fclose(fp); png_destroy_write_struct(&png_ptr, &info_ptr); return (ERROR); } @@ -693,9 +693,9 @@ * png_write_info_before_PLTE(write_ptr, write_info_ptr); * write_my_chunk(); * png_write_info(png_ptr, info_ptr); * - * However, given the level of known- and unknown-chunk support in 1.1.0 + * However, given the level of known- and unknown-chunk support in 1.2.0 * and up, this should no longer be necessary. */ /* Once we write out the header, the compression type on the text diff -ru4NwbB libpng-1.2.35/png.h libpng-1.2.36beta04/png.h --- libpng-1.2.35/png.h 2009-02-14 15:59:26.535979077 -0600 +++ libpng-1.2.36beta04/png.h 2009-04-06 19:29:16.091573902 -0500 @@ -221,8 +221,9 @@ * 1.0.43rc01-02 10 10043 10.so.0.43[.0] * 1.2.35rc01-02 13 10235 12.so.0.35[.0] * 1.0.43 10 10043 10.so.0.43[.0] * 1.2.35 13 10235 12.so.0.35[.0] + * 1.2.36beta01-04 13 10236 12.so.0.36[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be * used for changes in backward compatibility, as it is intended. The @@ -1986,8 +1987,13 @@ /* Replace the default data output functions with a user supplied one(s). * If buffered output is not used, then output_flush_fn can be set to NULL. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time * output_flush_fn will be ignored (and thus can be NULL). + * It is probably a mistake to use NULL for output_flush_fn if + * write_data_fn is not also NULL unless you have built libpng with + * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's + * default flush function, which uses the standard *FILE structure, will + * be used. */ extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); @@ -2555,13 +2561,14 @@ #else /* PNG_DEBUG_FILE || !_MSC_VER */ #ifndef PNG_DEBUG_FILE #define PNG_DEBUG_FILE stderr #endif /* PNG_DEBUG_FILE */ + #if (PNG_DEBUG > 1) -#ifndef png_debug /* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on * non-ISO compilers */ #ifdef __STDC__ +# ifndef png_debug #define png_debug(l,m) \ { \ int num_tabs=l; \ fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ @@ -2586,35 +2593,42 @@ #endif #else /* __STDC __ */ #ifndef png_debug #define png_debug(l,m) \ + { \ int num_tabs=l; \ char format[256]; \ snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ m,PNG_STRING_NEWLINE); \ - fprintf(PNG_DEBUG_FILE,format); + fprintf(PNG_DEBUG_FILE,format); \ + } #endif #ifndef png_debug1 #define png_debug1(l,m,p1) \ + { \ int num_tabs=l; \ char format[256]; \ snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ m,PNG_STRING_NEWLINE); \ - fprintf(PNG_DEBUG_FILE,format,p1); + fprintf(PNG_DEBUG_FILE,format,p1); \ + } #endif #ifndef png_debug2 #define png_debug2(l,m,p1,p2) \ + { \ int num_tabs=l; \ char format[256]; \ snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ m,PNG_STRING_NEWLINE); \ - fprintf(PNG_DEBUG_FILE,format,p1,p2); + fprintf(PNG_DEBUG_FILE,format,p1,p2); \ + } #endif #endif /* __STDC __ */ #endif /* (PNG_DEBUG > 1) */ + #endif /* _MSC_VER */ #endif /* (PNG_DEBUG > 0) */ #endif /* PNG_DEBUG */ #ifndef png_debug @@ -2707,8 +2721,9 @@ #if !defined(PNG_1_0_X) /* png.c, pnggccrd.c, or pngvcrd.c */ extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); +#endif /* PNG_1_0_X */ #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ /* Strip the prepended error numbers ("#nnn ") from error and warning * messages before passing them to the error or warning handler. */ @@ -2716,10 +2731,8 @@ extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp png_ptr, png_uint_32 strip_mode)); #endif -#endif /* PNG_1_0_X */ - /* Added at libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); diff -ru4NwbB libpng-1.2.35/pngerror.c libpng-1.2.36beta04/pngerror.c --- libpng-1.2.35/pngerror.c 2009-02-14 15:59:26.564665362 -0600 +++ libpng-1.2.36beta04/pngerror.c 2009-04-06 19:29:16.120307487 -0500 @@ -1,8 +1,8 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.2.34 [December 18, 2008] + * Last changed in libpng 1.2.36 [April 7, 2009] * 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) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -216,9 +216,9 @@ #ifndef PNG_NO_CONSOLE_IO #ifdef PNG_ERROR_NUMBERS_SUPPORTED if (*error_message == '#') { - /* Strip "#nnnn " from beginning of warning message. */ + /* Strip "#nnnn " from beginning of error message. */ int offset; char error_number[16]; for (offset = 0; offset<15; offset++) { @@ -228,17 +228,23 @@ } if ((offset > 1) && (offset < 15)) { error_number[offset - 1] = '\0'; - fprintf(stderr, "libpng error no. %s: %s\n", error_number, - error_message + offset + 1); + fprintf(stderr, "libpng error no. %s: %s", + error_number, error_message + offset + 1); + fprintf(stderr, PNG_STRING_NEWLINE); } else - fprintf(stderr, "libpng error: %s, offset=%d\n", error_message, offset); + fprintf(stderr, "libpng error: %s, offset=%d", + error_message, offset); + fprintf(stderr, PNG_STRING_NEWLINE); } else #endif - fprintf(stderr, "libpng error: %s\n", error_message); + { + fprintf(stderr, "libpng error: %s", error_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } #endif #ifdef PNG_SETJMP_SUPPORTED if (png_ptr) @@ -284,17 +290,25 @@ } if ((offset > 1) && (offset < 15)) { warning_number[offset + 1] = '\0'; - fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, - warning_message + offset); + fprintf(stderr, "libpng warning no. %s: %s", + warning_number, warning_message + offset); + fprintf(stderr, PNG_STRING_NEWLINE); } else - fprintf(stderr, "libpng warning: %s\n", warning_message); + { + fprintf(stderr, "libpng warning: %s", + warning_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } } else # endif - fprintf(stderr, "libpng warning: %s\n", warning_message); + { + fprintf(stderr, "libpng warning: %s", warning_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } #else warning_message = warning_message; /* make compiler happy */ #endif png_ptr = png_ptr; /* make compiler happy */ diff -ru4NwbB libpng-1.2.35/pngread.c libpng-1.2.36beta04/pngread.c --- libpng-1.2.35/pngread.c 2009-02-27 17:49:09.184770384 -0600 +++ libpng-1.2.36beta04/pngread.c 2009-04-06 19:29:16.154680716 -0500 @@ -1433,13 +1433,13 @@ if (info_ptr->row_pointers == NULL) { info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, info_ptr->height * png_sizeof(png_bytep)); + png_memset(info_ptr->row_pointers, 0, info_ptr->height + * png_sizeof(png_bytep)); #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_ROWS; #endif - png_memset(info_ptr->row_pointers, 0, info_ptr->height - * png_sizeof(png_bytep)); for (row = 0; row < (int)info_ptr->height; row++) info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); } diff -ru4NwbB libpng-1.2.35/pngrio.c libpng-1.2.36beta04/pngrio.c --- libpng-1.2.35/pngrio.c 2009-02-27 17:51:17.104471248 -0600 +++ libpng-1.2.36beta04/pngrio.c 2009-04-06 19:29:16.159820906 -0500 @@ -131,9 +131,11 @@ arguments a pointer to a png_struct, a pointer to a location where input data can be stored, and a 32-bit unsigned int that is the number of bytes to be read. To exit and output any fatal error messages the new write - function should call png_error(png_ptr, "Error msg"). */ + function should call png_error(png_ptr, "Error msg"). + May be NULL, in which case libpng's default function will + be used. */ void PNGAPI png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn) { diff -ru4NwbB libpng-1.2.35/pngrtran.c libpng-1.2.36beta04/pngrtran.c --- libpng-1.2.35/pngrtran.c 2009-02-27 17:51:00.108616289 -0600 +++ libpng-1.2.36beta04/pngrtran.c 2009-04-06 19:29:16.173976014 -0500 @@ -4124,16 +4122,15 @@ g = 1.0; png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, (png_uint_32)(num * png_sizeof(png_uint_16p))); + png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p)); if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) { double fin, fout; png_uint_32 last, max; - png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p)); - for (i = 0; i < num; i++) { png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, (png_uint_32)(256 * png_sizeof(png_uint_16))); diff -ru4NwbB libpng-1.2.35/pngrutil.c libpng-1.2.36beta04/pngrutil.c --- libpng-1.2.35/pngrutil.c 2009-02-14 15:59:26.630905530 -0600 +++ libpng-1.2.36beta04/pngrutil.c 2009-04-06 19:29:16.187060020 -0500 @@ -1,10 +1,10 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.2.34 [December 18, 2008] + * Last changed in libpng 1.2.36 [April 7, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * Copyright (c) 1998-2009 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.) * * This file contains routines that are only called from within @@ -3187,8 +3187,10 @@ if (row_bytes + 64 > png_ptr->old_big_row_buf_size) { png_free(png_ptr, png_ptr->big_row_buf); png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64); + if (png_ptr->interlaced) + png_memset(png_ptr->big_row_buf, 0, png_ptr->rowbytes + 64); png_ptr->row_buf = png_ptr->big_row_buf+32; png_ptr->old_big_row_buf_size = row_bytes+64; } diff -ru4NwbB libpng-1.2.35/pngset.c libpng-1.2.36beta04/pngset.c --- libpng-1.2.35/pngset.c 2009-02-27 17:50:44.248728306 -0600 +++ libpng-1.2.36beta04/pngset.c 2009-04-06 19:29:16.194993985 -0500 @@ -382,12 +382,8 @@ png_warning(png_ptr, "Insufficient memory for pCAL params."); return; } -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_PCAL; -#endif - png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp)); for (i = 0; i < nparams; i++) { @@ -403,8 +399,11 @@ png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); } info_ptr->valid |= PNG_INFO_pCAL; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_PCAL; +#endif } #endif #if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) diff -ru4NwbB libpng-1.2.35/pngtest.c libpng-1.2.36beta04/pngtest.c --- libpng-1.2.35/pngtest.c 2009-02-14 15:59:26.647524575 -0600 +++ libpng-1.2.36beta04/pngtest.c 2009-04-06 19:29:16.203585802 -0500 @@ -1,10 +1,10 @@ /* pngtest.c - a simple test program to test libpng * - * Last changed in libpng 1.2.32 [September 18, 2008] + * Last changed in libpng 1.2.36 [April 7, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * Copyright (c) 1998-2009 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.) * * This program reads in a PNG image, writes it out again, and then @@ -361,14 +361,10 @@ #if defined(PNG_WRITE_FLUSH_SUPPORTED) static void pngtest_flush(png_structp png_ptr) { -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif + /* Do nothing; fflush() is said to be just a waste of energy. */ + png_ptr = png_ptr; /* stifle compiler warning */ } #endif /* This is the function that does the actual writing of data. If you are diff -ru4NwbB libpng-1.2.35/pngwio.c libpng-1.2.36beta04/pngwio.c --- libpng-1.2.35/pngwio.c 2009-02-27 17:50:49.640399946 -0600 +++ libpng-1.2.36beta04/pngwio.c 2009-04-06 19:29:16.219885193 -0500 @@ -1,8 +1,8 @@ /* pngwio.c - functions for data output * - * Last changed in libpng 1.2.35 [February 14, 2009] + * Last changed in libpng 1.2.36 [April 7, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 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.) @@ -136,9 +136,8 @@ #endif if (png_ptr == NULL) return; #if !defined(_WIN32_WCE) io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL && fileno(io_ptr) != -1) fflush(io_ptr); #endif } #endif @@ -155,18 +154,24 @@ arguments a pointer to a png_struct, a pointer to data to be written, and a 32-bit unsigned int that is the number of bytes to be written. The new write function should call png_error(png_ptr, "Error msg") - to exit and output any fatal error messages. + to exit and output any fatal error messages. May be + NULL, in which case libpng's default function will + be used. flush_data_fn - pointer to a new flush function that takes as its arguments a pointer to a png_struct. After a call to the flush function, there should be no data in any buffers or pending transmission. If the output method doesn't do any buffering of ouput, a function prototype must still be supplied although it doesn't have to do anything. If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time, output_flush_fn will be ignored, although it must be - supplied for compatibility. */ + supplied for compatibility. May be NULL, in which case + libpng's default function will be used, if + PNG_WRITE_FLUSH_SUPPORTED is defined. This is not + a good idea if io_ptr does not point to a standard + *FILE structure. */ void PNGAPI png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) { diff -ru4NwbB libpng-1.2.35/pngwutil.c libpng-1.2.36beta04/pngwutil.c --- libpng-1.2.35/pngwutil.c 2009-02-14 15:59:26.688440709 -0600 +++ libpng-1.2.36beta04/pngwutil.c 2009-04-06 19:29:16.244687530 -0500 @@ -1,10 +1,10 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.2.34 [December 18, 2008] + * Last changed in libpng 1.2.36 [April 7, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * Copyright (c) 1998-2009 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.) */ @@ -784,8 +784,9 @@ if (profile_len < embedded_profile_len) { png_warning(png_ptr, "Embedded profile length too large in iCCP chunk"); + png_free(png_ptr, new_name); return; } if (profile_len > embedded_profile_len)