From a8dc4523c770c2c560d1ef0f275fd17410677d54 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Fri, 14 Apr 2000 14:56:16 -0500 Subject: [PATCH] Imported from pngcrush-1.4.2.tar --- png.c | 12 ++--- png.h | 72 +++++++++++++++---------- pngasmrd.h | 2 +- pngconf.h | 2 +- pngcrush.c | 155 +++++++++++++++++------------------------------------ pngcrush.h | 2 + pngerror.c | 2 +- pnggccrd.c | 2 +- pngget.c | 2 +- pngmem.c | 2 +- pngpread.c | 2 +- pngread.c | 9 ++-- pngrio.c | 2 +- pngrtran.c | 2 +- pngrutil.c | 20 ++++--- pngset.c | 48 ++++++++++------- pngtrans.c | 2 +- pngvcrd.c | 2 +- pngwio.c | 2 +- pngwrite.c | 2 +- pngwtran.c | 2 +- pngwutil.c | 2 +- 22 files changed, 162 insertions(+), 186 deletions(-) diff --git a/png.c b/png.c index 508c8f11a..f84227502 100644 --- a/png.c +++ b/png.c @@ -1,7 +1,7 @@ /* png.c - location for general purpose libpng functions * - * libpng version 1.0.6e - April 9, 2000 + * libpng version 1.0.6f - April 14, 2000 * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson @@ -14,14 +14,14 @@ #include "png.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_0_6e Your_png_h_is_not_version_1_0_6e; +typedef version_1_0_6f Your_png_h_is_not_version_1_0_6f; /* Version information for C files. This had better match the version * string defined in png.h. */ #ifdef PNG_USE_GLOBAL_ARRAYS /* png_libpng_ver was changed to a function in version 1.0.5c */ -char png_libpng_ver[12] = "1.0.6e"; +char png_libpng_ver[12] = "1.0.6f"; /* png_sig was changed to a function in version 1.0.5c */ /* Place to hold the signature string for a PNG file. */ @@ -561,7 +561,7 @@ png_charp png_get_copyright(png_structp png_ptr) { if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */ - return ("\n libpng version 1.0.6e - April 9, 2000\n\ + return ("\n libpng version 1.0.6f - April 14, 2000\n\ Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\ Copyright (c) 1996, 1997 Andreas Dilger\n\ Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson\n"); @@ -579,8 +579,8 @@ png_get_libpng_ver(png_structp png_ptr) { /* Version of *.c files used when building libpng */ if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return("1.0.6e"); - return("1.0.6e"); + return("1.0.6f"); + return("1.0.6f"); } png_charp diff --git a/png.h b/png.h index d7b31f5cd..d4b90758c 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.0.6e - April 9, 2000 + * libpng version 1.0.6f - April 14, 2000 * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson @@ -9,7 +9,7 @@ * Authors and maintainers: * 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.97, January 1998, through 1.0.6e - April 9, 2000: Glenn + * libpng versions 0.97, January 1998, through 1.0.6f - April 14, 2000: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -47,7 +47,7 @@ * 1.0.5e-r 1.0.5e-r 10100 2.1.0.5e-r (not compatible) * 1.0.5s-v 1.0.5s-v 10006 2.1.0.5s-v (compatible) * 1.0.6 (+ 3 patches) 1.0.6 10006 2.1.0.6 - * 1.0.6d-e 1.0.6d-e 10007 2.1.0.6d-e + * 1.0.6d-f 1.0.6d-f 10007 2.1.0.6d-f * 1.0.7 1.0.7 10007 2.1.0.7 (still compatible) * * Henceforth the source version will match the shared-library minor @@ -73,7 +73,7 @@ * Copyright (c) 1996, 1997 Andreas Dilger * (libpng versions 0.89c, June 1996, through 0.96, May 1997) * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson - * (libpng versions 0.97, January 1998, through 1.0.6e, April 9, 2000) + * (libpng versions 0.97, January 1998, through 1.0.6f, April 14, 2000) * * For the purposes of this copyright and license, "Contributing Authors" * is defined as the following set of individuals: @@ -148,13 +148,13 @@ * Y2K compliance in libpng: * ========================= * - * April 9, 2000 + * April 14, 2000 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.0.6e are Y2K compliant. It is my belief that earlier + * upward through 1.0.6f are Y2K compliant. It is my belief that earlier * versions were also Y2K compliant. * * Libpng only has three year fields. One is a 2-byte unsigned integer @@ -232,7 +232,7 @@ extern "C" { */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.0.6e" +#define PNG_LIBPNG_VER_STRING "1.0.6f" /* Careful here. At one time, Guy wanted to use 082, but that would be octal. * We must not include leading zeros. @@ -323,12 +323,17 @@ typedef struct png_sPLT_entry_struct typedef png_sPLT_entry FAR * png_sPLT_entryp; typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; +/* When the depth of the sPLT palette is 8 bits, the color and alpha samples + * occupy the LSB of their respective members, and the MSB of each member + * is zero-filled. The frequency member always occupies the full 16 bits. + */ + typedef struct png_sPLT_struct { - png_charp name; /* palette name */ - png_byte depth; /* depth of palette samples */ - png_sPLT_entryp entries; /* palette entries */ - png_int_32 nentries; /* number of palette entries */ + png_charp name; /* palette name */ + png_byte depth; /* depth of palette samples */ + png_sPLT_entryp entries; /* palette entries */ + png_int_32 nentries; /* number of palette entries */ } png_sPLT_t; typedef png_sPLT_t FAR * png_sPLT_tp; typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; @@ -336,21 +341,28 @@ typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; #ifdef PNG_TEXT_SUPPORTED /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, * and whether that contents is compressed or not. The "key" field - * points to a regular C string. */ + * points to a regular zero-terminated C string. The "text", "lang", and + * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. + * However, the * structure returned by png_get_text() will always contain + * regular zero-terminated C strings (possibly empty), never NULL pointers, + * so they can be safely used in printf() and other string-handling functions. + */ typedef struct png_text_struct { - int compression; /* compression value: - -1: tEXt, none - 0: zTXt, deflate - 1: iTXt, none - 2: iTXt, deflate */ + int compression; /* compression value: + -1: tEXt, none + 0: zTXt, deflate + 1: iTXt, none + 2: iTXt, deflate */ png_charp key; /* keyword, 1-79 character description of "text" */ - png_charp text; /* comment, may be an empty string (ie "") */ + png_charp text; /* comment, may be an empty string (ie "") + or a NULL pointer */ png_size_t text_length; /* length of the text string */ png_size_t itxt_length; /* length of the itxt string */ - png_charp lang; /* language code, 1-79 characters */ + png_charp lang; /* language code, 0-79 characters + or a NULL pointer */ png_charp lang_key; /* keyword translated UTF-8 string, 0 or more - chars */ + chars or a NULL pointer */ } png_text; typedef png_text FAR * png_textp; typedef png_text FAR * FAR * png_textpp; @@ -1061,9 +1073,9 @@ struct png_struct_def }; /* This prevents a compiler error in png_get_copyright() in png.c if png.c -and png.h are both at * version 1.0.6e +and png.h are both at * version 1.0.6f */ -typedef png_structp version_1_0_6e; +typedef png_structp version_1_0_6f; typedef png_struct FAR * FAR * png_structpp; @@ -1910,18 +1922,20 @@ extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, png_infop info_ptr, png_sPLT_tp entries, int nentries)); #endif -#if defined(PNG_TEXT_SUPPORTED) -extern PNG_EXPORT(void,png_set_itxt) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - #if defined(PNG_READ_TEXT_SUPPORTED) -/* Old interface; apps should use png_get_itxt instead */ /* png_get_text also returns the number of text chunks in *num_text */ extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, int *num_text)); #endif +/* + * Note while png_set_text() will accept a structure whose text, + * language, and translated keywords are NULL pointers, the structure + * returned by png_get_text will always contain regular + * zero-terminated C strings. They might be empty strings but + * they will never be NULL pointers. + */ + #if defined(PNG_TEXT_SUPPORTED) extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, int num_text)); @@ -2044,7 +2058,7 @@ extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr) extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.0.6e - April 9, 2000 (header)\n" + " libpng version 1.0.6f - April 14, 2000 (header)\n" #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on diff --git a/pngasmrd.h b/pngasmrd.h index 9f6aad53c..e17994b25 100644 --- a/pngasmrd.h +++ b/pngasmrd.h @@ -1,6 +1,6 @@ /* pngasmrd.h - assembler version of utilities to read a PNG file * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1999, 2000 Glenn Randers-Pehrson * diff --git a/pngconf.h b/pngconf.h index f9400b01a..33b6bd21c 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngcrush.c b/pngcrush.c index f7632379f..a22fe8a83 100644 --- a/pngcrush.c +++ b/pngcrush.c @@ -15,7 +15,7 @@ * occasionally creating Linux executables. */ -#define PNGCRUSH_VERSION "1.4.1" +#define PNGCRUSH_VERSION "1.4.2" /* * COPYRIGHT NOTICE, DISCLAIMER, AND LICENSE: @@ -45,26 +45,15 @@ * or altered from any source or altered source distribution. */ -/* To do: +/* Change log: * - * Version 1.4.*: check for unused alpha channel and ok-to-reduce-depth. - * Rearrange palette to put most-used color first and transparent color - * second (see ImageMagick 5.1.1 and later). - * Finish pplt (partial palette) feature. + * Version 1.4.2 (built with libpng-1.0.6f and cexcept-0.6.0) * - * Version 1.4.*: Use an alternate write function for the trial passes, that - * simply counts bytes rather than actually writing to a file, to save wear - * and tear on disk drives. + * Removes extra IDAT chunks (such as found in some POV-ray PNGs) with + * a warning instead of bailing out (this feature requires libpng-1.0.6f + * or later, compiled with "#define PNG_ABORT()"). * - * Version 1.4.*: Allow in-place file replacement or as a filter, as in - * "pngcrush -overwrite file.png" - * "pngcreator | pngcrush > output.png" - * - * Version 1.4.*: Remove text-handling and color-handling features and put - * those in a separate program or programs, to avoid unnecessary - * recompressing. - * - * Change log: + * Removed old setjmp interface entirely. * * Version 1.4.1 (built with libpng-1.0.6e and cexcept-0.6.0) * @@ -187,7 +176,25 @@ * types, compression levels, or compression strategies. */ -#define USE_CEXCEPT +/* To do: + * + * Version 1.4.*: check for unused alpha channel and ok-to-reduce-depth. + * Rearrange palette to put most-used color first and transparent color + * second (see ImageMagick 5.1.1 and later). + * Finish pplt (partial palette) feature. + * + * Version 1.4.*: Use an alternate write function for the trial passes, that + * simply counts bytes rather than actually writing to a file, to save wear + * and tear on disk drives. + * + * Version 1.4.*: Allow in-place file replacement or as a filter, as in + * "pngcrush -overwrite file.png" + * "pngcreator | pngcrush > output.png" + * + * Version 1.4.*: Remove text-handling and color-handling features and put + * those in a separate program or programs, to avoid unnecessary + * recompressing. + */ #if defined(__DJGPP__) # if ((__DJGPP__ == 2) && (__DJGPP_MINOR__ == 0)) @@ -227,9 +234,6 @@ #if (PNG_LIBPNG_VER > 95) /* so we can load pngcrush with pre-1.0.6 versions of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif #if (PNG_LIBPNG_VER < 10006) /* These shorter macros weren't defined until version 1.0.6 */ @@ -299,7 +303,6 @@ int best; char buffer[256]; char *str_return; -#ifdef USE_CEXCEPT /* The cexcept documentation recommends putting the following three lines in a * separate header file, but it appears to work with them embedded here. * There is only one "Throw" and it is in this file. */ @@ -309,15 +312,6 @@ extern struct exception_context the_exception_context[1]; struct exception_context the_exception_context[1]; -#else -#ifndef PNG_JMPBUF_SUPPORTED -#ifndef PNG_SETJMP_NOT_SUPPORTED -/* Old setjmp interface */ -jmp_buf jmpbuf; -#endif -#endif -#endif - static png_uint_32 total_input_length = 0; static png_uint_32 total_output_length = 0; static int pngcrush_mode = DEFAULT_MODE; @@ -405,15 +399,25 @@ int ia; /* cexcept interface */ -#ifdef USE_CEXCEPT static void png_cexcept_error(png_structp png_ptr, png_const_charp msg) { if(png_ptr) ; +#if (PNG_LIBPNG_VER > 10006) + if (!strcmp(msg, "Too many IDAT's found")) + { +#ifndef PNG_NO_CONSOLE_IO + fprintf(stderr, "Correcting "); +#else + png_warning(png_ptr, msg); +#endif + /* png_ptr->mode |= PNG_AFTER_IDAT; */ + } + else +#endif Throw msg; } -#endif /* START of code to validate memory allocation and deallocation */ #ifdef PNG_USER_MEM_SUPPORTED @@ -1603,11 +1607,9 @@ main(int argc, char *argv[]) for(;;) /* loop on input files */ { -#ifdef USE_CEXCEPT png_const_charp msg; Try { -#endif first_trial = 1; if(png_row_filters != NULL) @@ -1866,38 +1868,22 @@ main(int argc, char *argv[]) png_debug(0, "Allocating read and write structures\n"); #ifdef PNG_USER_MEM_SUPPORTED read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, -#ifdef USE_CEXCEPT (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL, (png_voidp)NULL, -#else - (png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL, -#endif (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); #else read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, -#ifdef USE_CEXCEPT (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL); -#else - (png_error_ptr)NULL, (png_error_ptr)NULL); -#endif #endif if(nosave == 0) { #ifdef PNG_USER_MEM_SUPPORTED write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, -#ifdef USE_CEXCEPT (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL, (png_voidp)NULL, -#else - (png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL, -#endif (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); #else write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, -#ifdef USE_CEXCEPT (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL); -#else - (png_error_ptr)NULL, (png_error_ptr)NULL); -#endif #endif } @@ -1913,38 +1899,6 @@ main(int argc, char *argv[]) P2("structures created.\n"); png_crush_pause(); - png_debug(0, "Setting jmpbuf for read and write structs\n"); -#ifndef PNG_SETJMP_NOT_SUPPORTED -# ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -# else - if (setjmp(png_jmpbuf(read_ptr))) -# endif - { - PNG_CRUSH_CLEANUP - continue; - } - -#if defined(USE_FAR_KEYWORD) - png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf)); -#endif - if(nosave == 0) -# ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -# else - if (setjmp(png_jmpbuf(write_ptr))) -# endif - { - PNG_CRUSH_CLEANUP - continue; - } -#if defined(USE_FAR_KEYWORD) - png_memcpy(png_jmpbuf(write_ptr),jmpbuf,sizeof(jmp_buf)); -#endif - P2("jmp_buf has been set.\n"); - png_crush_pause(); -#endif - png_debug(0, "Initializing input and output streams\n"); #if !defined(PNG_NO_STDIO) png_init_io(read_ptr, fpin); @@ -3250,14 +3204,12 @@ main(int argc, char *argv[]) if(verbose > 0) show_result(); return 0; } -#ifdef USE_CEXCEPT } Catch (msg) { fprintf(stderr, "Caught libpng error:\n %s\n\n",msg); PNG_CRUSH_CLEANUP } -#endif } /* end of loop on input files */ } @@ -3265,35 +3217,17 @@ png_uint_32 measure_idats(FILE *fpin) { png_uint_32 measured_idat_length; + png_const_charp msg; P2("measure_idats:\n"); png_debug(0, "Allocating read structure\n"); read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, -#ifdef USE_CEXCEPT (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL); -#else - (png_error_ptr)NULL, (png_error_ptr)NULL); -#endif png_debug(0, "Allocating read_info, end_info structures\n"); read_info_ptr = png_create_info_struct(read_ptr); end_info_ptr = png_create_info_struct(read_ptr); - png_debug(0, "Setting jmpbuf for read struct\n"); -#ifndef PNG_SETJMP_NOT_SUPPORTED -# ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -# else - if (setjmp(png_jmpbuf(read_ptr))) -# endif - { - PNG_CRUSH_CLEANUP - P2("returning from measure_idats after longjump\n"); - return 0; - } - -# if defined(USE_FAR_KEYWORD) - png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf)); -# endif -#endif + Try + { #if !defined(PNG_NO_STDIO) png_init_io(read_ptr, fpin); @@ -3307,6 +3241,13 @@ measure_idats(FILE *fpin) png_debug(0, "Destroying data structs\n"); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); return measured_idat_length; + } + Catch (msg) + { + PNG_CRUSH_CLEANUP + P2("Measure_idats caught libpng error:\n %s\n\n",msg); + } + return 0; } diff --git a/pngcrush.h b/pngcrush.h index 0a509b973..665dba49e 100644 --- a/pngcrush.h +++ b/pngcrush.h @@ -66,4 +66,6 @@ #endif #endif +#define PNG_ABORT() + #endif diff --git a/pngerror.c b/pngerror.c index 2db55bee2..fd606c0a7 100644 --- a/pngerror.c +++ b/pngerror.c @@ -1,7 +1,7 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pnggccrd.c b/pnggccrd.c index 23bb994ef..a85ffcd5d 100644 --- a/pnggccrd.c +++ b/pnggccrd.c @@ -6,7 +6,7 @@ * and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm * for Intel's performance analysis of the MMX vs. non-MMX code. * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998, Intel Corporation * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson diff --git a/pngget.c b/pngget.c index c0b3dc01a..c250e5ec0 100644 --- a/pngget.c +++ b/pngget.c @@ -1,7 +1,7 @@ /* pngget.c - retrieval of values from info struct * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngmem.c b/pngmem.c index 66a7eb695..0cfc89fd5 100644 --- a/pngmem.c +++ b/pngmem.c @@ -1,7 +1,7 @@ /* pngmem.c - stub functions for memory allocation * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngpread.c b/pngpread.c index ebac35bea..18ea85b81 100644 --- a/pngpread.c +++ b/pngpread.c @@ -1,7 +1,7 @@ /* pngpread.c - read a png file in push mode * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngread.c b/pngread.c index a95ea2368..0b2df736c 100644 --- a/pngread.c +++ b/pngread.c @@ -1,7 +1,7 @@ /* pngread.c - read a PNG file * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -641,7 +641,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) * not called png_set_interlace_handling(), the display_row buffer will * be ignored, so pass NULL to it. * - * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6e. + * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6f. */ void @@ -690,7 +690,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row, * only call this function once. If you desire to have an image for * each pass of a interlaced image, use png_read_rows() instead. * - * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6e. + * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6f. */ void png_read_image(png_structp png_ptr, png_bytepp image) @@ -834,8 +834,7 @@ png_read_end(png_structp png_ptr, png_infop info_ptr) */ if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT) png_error(png_ptr, "Too many IDAT's found"); - else - png_crc_finish(png_ptr, 0); + png_crc_finish(png_ptr, length); } else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_handle_PLTE(png_ptr, info_ptr, length); diff --git a/pngrio.c b/pngrio.c index 801d930cd..ce9ade3d7 100644 --- a/pngrio.c +++ b/pngrio.c @@ -1,7 +1,7 @@ /* pngrio.c - functions for data input * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngrtran.c b/pngrtran.c index a3a971e1f..f442ef7fa 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngrutil.c b/pngrutil.c index 79eeaa03a..fc89edeae 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -133,7 +133,7 @@ png_crc_error(png_structp png_ptr) } #if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ - defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_sPLT_SUPPORTED) + defined(PNG_READ_iCCP_SUPPORTED) /* * Decompress trailing data in a chunk. The assumption is that chunkdata * points at an allocated area holding the contents of a chunk with a @@ -951,7 +951,8 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) if (profile >= chunkdata + slength) { png_free(png_ptr, chunkdata); - png_error(png_ptr, "malformed iCCP chunk"); + png_warning(png_ptr, "malformed iCCP chunk"); + return; } /* compression should always be zero */ @@ -1019,7 +1020,8 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) if (entry_start > chunkdata + slength) { png_free(png_ptr, chunkdata); - png_error(png_ptr, "malformed sPLT chunk"); + png_warning(png_ptr, "malformed sPLT chunk"); + return; } new_palette.depth = *entry_start++; @@ -1563,7 +1565,10 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) #ifdef PNG_FLOATING_POINT_SUPPORTED width = strtod(ep, &vp); if (*vp) - png_error(png_ptr, "malformed width string in sCAL chunk"); + { + png_warning(png_ptr, "malformed width string in sCAL chunk"); + return; + } #else #ifdef PNG_FIXED_POINT_SUPPORTED swidth = (png_charp)png_malloc(png_ptr, strlen(ep) + 1); @@ -1578,7 +1583,10 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) #ifdef PNG_FLOATING_POINT_SUPPORTED height = strtod(ep, &vp); if (*vp) - png_error(png_ptr, "malformed height string in sCAL chunk"); + { + png_warning(png_ptr, "malformed height string in sCAL chunk"); + return; + } #else #ifdef PNG_FIXED_POINT_SUPPORTED sheight = (png_charp)png_malloc(png_ptr, strlen(ep) + 1); diff --git a/pngset.c b/pngset.c index 39e23f819..c4442a89e 100644 --- a/pngset.c +++ b/pngset.c @@ -1,7 +1,7 @@ /* pngset.c - storage of image information into info struct * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger @@ -421,18 +421,25 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr, png_charp name, int compression_type, png_charp profile, png_uint_32 proflen) { + png_charp new_iccp_name; + png_charp new_iccp_profile; + png_debug1(1, "in %s storage function\n", "iCCP"); if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) return; + new_iccp_name = png_malloc(png_ptr, png_strlen(name)+1); + strcpy(new_iccp_name, name); + new_iccp_profile = png_malloc(png_ptr, proflen); + png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); + png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); - info_ptr->iccp_name = png_malloc(png_ptr, png_strlen(name)+1); - strcpy(info_ptr->iccp_name, name); - info_ptr->iccp_profile = png_malloc(png_ptr, proflen); - png_memcpy(info_ptr->iccp_profile, profile, (png_size_t)proflen); + info_ptr->iccp_proflen = proflen; + info_ptr->iccp_name = new_iccp_name; + info_ptr->iccp_profile = new_iccp_profile; /* Compression is always zero but is here so the API and info structure - * does not have to change * if we introduce multiple compression types */ + * does not have to change if we introduce multiple compression types */ info_ptr->iccp_compression = (png_byte)compression_type; info_ptr->free_me |= PNG_FREE_ICCP; info_ptr->valid |= PNG_INFO_iCCP; @@ -495,8 +502,14 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, if(text_ptr[i].compression > 0) { /* set iTXt data */ - lang_len = png_strlen(text_ptr[i].lang); - lang_key_len = png_strlen(text_ptr[i].lang_key); + if (text_ptr[i].key != (png_charp)NULL) + lang_len = png_strlen(text_ptr[i].lang); + else + lang_len = 0; + if (text_ptr[i].lang_key != (png_charp)NULL) + lang_key_len = png_strlen(text_ptr[i].lang_key); + else + lang_key_len = 0; } else { @@ -504,7 +517,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, lang_key_len = 0; } - if (text_ptr[i].text[0] == '\0') + if (text_ptr[i].text == (png_charp)NULL || text_ptr[i].text[0] == '\0') { text_length = 0; if(text_ptr[i].compression > 0) @@ -538,19 +551,15 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, } else { - textp->lang=NULL; - textp->lang_key=NULL; + textp->lang=(png_charp)NULL; + textp->lang_key=(png_charp)NULL; textp->text=textp->key + key_len + 1; } if(text_length) - { png_memcpy(textp->text, text_ptr[i].text, (png_size_t)(text_length)); - *(textp->text+text_length) = '\0'; - } - else - textp->text--; + *(textp->text+text_length) = '\0'; if(textp->compression > 0) { @@ -755,8 +764,11 @@ png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) if (png_ptr == NULL || info_ptr == NULL) return; - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); - info_ptr->row_pointers = row_pointers; + if(info_ptr->row_pointers != row_pointers) + { + png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); + info_ptr->row_pointers = row_pointers; + } } #endif diff --git a/pngtrans.c b/pngtrans.c index e95c0fc69..6d3fd60c3 100644 --- a/pngtrans.c +++ b/pngtrans.c @@ -1,7 +1,7 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngvcrd.c b/pngvcrd.c index c2d443a75..a0f1f423f 100644 --- a/pngvcrd.c +++ b/pngvcrd.c @@ -2,7 +2,7 @@ * * For Intel x86 CPU and Microsoft Visual C++ compiler * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998, Intel Corporation * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson diff --git a/pngwio.c b/pngwio.c index 86296533d..2701b79d0 100644 --- a/pngwio.c +++ b/pngwio.c @@ -1,7 +1,7 @@ /* pngwio.c - functions for data output * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngwrite.c b/pngwrite.c index 4a395fbd1..266ff2f2d 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,7 +1,7 @@ /* pngwrite.c - general routines to write a PNG file * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngwtran.c b/pngwtran.c index bb40cf93b..2669eaa08 100644 --- a/pngwtran.c +++ b/pngwtran.c @@ -1,7 +1,7 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger diff --git a/pngwutil.c b/pngwutil.c index eb4c13ec2..4dd5ec316 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1,7 +1,7 @@ /* pngwutil.c - utilities to write a PNG file * - * libpng 1.0.6e - April 9, 2000 + * libpng 1.0.6f - April 14, 2000 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger