diff -ru4N libpng-1.2.24/png.c libpng-1.2.25rc02/png.c --- libpng-1.2.24/png.c 2007-12-14 10:22:30.000000000 -0600 +++ libpng-1.2.25rc02/png.c 2008-02-10 15:28:40.433173000 -0600 @@ -693,9 +693,9 @@ png_get_copyright(png_structp png_ptr) { png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ return ((png_charp) "\n libpng version 1.2.25rc02 - February 10, 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) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); } diff -ru4N libpng-1.2.24/png.h libpng-1.2.25rc02/png.h --- libpng-1.2.24/png.h 2007-12-14 10:22:29.000000000 -0600 +++ libpng-1.2.25rc02/png.h 2008-02-10 15:28:40.277585000 -0600 @@ -1,9 +1,9 @@ /* png.h - header file for PNG reference library * * libpng version 1.2.25rc02 - February 10, 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.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * Authors and maintainers: @@ -174,8 +174,10 @@ * 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] * * 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 @@ -204,9 +206,9 @@ * If you modify libpng you may insert additional notices immediately following * this sentence. * * libpng versions 1.2.6, August 15, 2004, through 1.2.25rc02, February 10, 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 * with the following individual added to the list of Contributing Authors: * * Cosmin Truta diff -ru4N libpng-1.2.24/pngconf.h libpng-1.2.25rc02/pngconf.h --- libpng-1.2.24/pngconf.h 2007-12-14 10:22:29.000000000 -0600 +++ libpng-1.2.25rc02/pngconf.h 2008-02-10 15:28:40.349439000 -0600 @@ -2,9 +2,9 @@ /* pngconf.h - machine configurable file for libpng * * libpng version 1.2.25rc02 - February 10, 2008 * 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.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ diff -ru4N libpng-1.2.24/pngpread.c libpng-1.2.25rc02/pngpread.c --- libpng-1.2.24/pngpread.c 2007-12-14 10:22:30.000000000 -0600 +++ libpng-1.2.25rc02/pngpread.c 2008-02-10 15:28:40.636497000 -0600 @@ -1,10 +1,10 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.2.23 [November 6, 2007] + * Last changed in libpng 1.2.25 [February 10, 2008] * 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.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ @@ -27,9 +27,9 @@ void PNGAPI png_process_data(png_structp png_ptr, png_infop info_ptr, 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); while (png_ptr->buffer_size) { @@ -1017,34 +1017,39 @@ png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); do { - png_ptr->pass++; - if ((png_ptr->pass == 1 && png_ptr->width < 5) || - (png_ptr->pass == 3 && png_ptr->width < 3) || - (png_ptr->pass == 5 && png_ptr->width < 2)) - png_ptr->pass++; - - if (png_ptr->pass > 7) - png_ptr->pass--; - if (png_ptr->pass >= 7) - break; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1; - - if (png_ptr->transformations & PNG_INTERLACE) - break; - - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; + int pass; + pass = png_ptr->pass; + pass++; + if ((pass == 1 && png_ptr->width < 5) || + (pass == 3 && png_ptr->width < 3) || + (pass == 5 && png_ptr->width < 2)) + pass++; + + if (pass > 7) + pass--; + png_ptr->pass = (png_byte) pass; + if (pass < 7) + { + png_ptr->iwidth = (png_ptr->width + + png_pass_inc[pass] - 1 - + png_pass_start[pass]) / + png_pass_inc[pass]; + + png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, + png_ptr->iwidth) + 1; + + if (png_ptr->transformations & PNG_INTERLACE) + break; + + png_ptr->num_rows = (png_ptr->height + + png_pass_yinc[pass] - 1 - + png_pass_ystart[pass]) / + png_pass_yinc[pass]; + } + else + break; } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); } } @@ -1516,11 +1521,11 @@ png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); } } -#else - png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); + else #endif + png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); png_free(png_ptr, png_ptr->unknown_chunk.data); png_ptr->unknown_chunk.data = NULL; } else diff -ru4N libpng-1.2.24/pngread.c libpng-1.2.25rc02/pngread.c --- libpng-1.2.24/pngread.c 2008-01-09 10:56:17.737928000 -0600 +++ libpng-1.2.25rc02/pngread.c 2008-02-10 15:28:40.700727000 -0600 @@ -1,10 +1,10 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.2.24 [December 14, 2007] + * Last changed in libpng 1.2.25 [February 10, 2008] * 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.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This file contains routines that an application calls directly to @@ -88,14 +88,20 @@ #endif png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - i=0; - do + if(user_png_ver) { - 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; - } while (png_libpng_ver[i++]); + if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) { /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so @@ -317,9 +323,9 @@ */ void PNGAPI 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"); /* If we haven't checked all of the PNG signature bytes, do so now. */ if (png_ptr->sig_bytes < 8) { @@ -1106,13 +1112,16 @@ png_debug(1, "in png_destroy_read_struct\n"); if (png_ptr_ptr != NULL) { 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; + free_fn = png_ptr->free_fn; + mem_ptr = png_ptr->mem_ptr; #endif - } if (info_ptr_ptr != NULL) info_ptr = *info_ptr_ptr; @@ -1149,18 +1158,15 @@ #endif *end_info_ptr_ptr = NULL; } - if (png_ptr != NULL) - { #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); + png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); #else - png_destroy_struct((png_voidp)png_ptr); + png_destroy_struct((png_voidp)png_ptr); #endif - *png_ptr_ptr = NULL; - } + *png_ptr_ptr = NULL; } /* free all memory used by the read (old method) */ void /* PRIVATE */ diff -ru4N libpng-1.2.24/pngrtran.c libpng-1.2.25rc02/pngrtran.c --- libpng-1.2.24/pngrtran.c 2007-12-14 10:22:31.000000000 -0600 +++ libpng-1.2.25rc02/pngrtran.c 2008-02-10 15:28:40.878017000 -0600 @@ -1,10 +1,10 @@ /* 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 10, 2008] * 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.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This file contains functions optionally called by an application @@ -963,8 +963,16 @@ palette[i].green = png_ptr->gamma_table[palette[i].green]; 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) */ else /* color_type != PNG_COLOR_TYPE_PALETTE */ @@ -1037,8 +1045,11 @@ palette[i].red = png_ptr->gamma_table[palette[i].red]; palette[i].green = png_ptr->gamma_table[palette[i].green]; 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) else @@ -1074,8 +1085,12 @@ png_composite(palette[i].blue, palette[i].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 */ #if defined(PNG_READ_SHIFT_SUPPORTED) diff -ru4N libpng-1.2.24/pngrutil.c libpng-1.2.25rc02/pngrutil.c --- libpng-1.2.24/pngrutil.c 2007-12-14 10:22:31.000000000 -0600 +++ libpng-1.2.25rc02/pngrutil.c 2008-02-10 15:28:40.992286000 -0600 @@ -1,10 +1,10 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.2.23 [November 6, 2007] + * Last changed in libpng 1.2.25 [February 10, 2008] * 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.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This file contains routines that are only called from within @@ -229,9 +229,9 @@ /* Copy what we can of the error message into the text chunk */ text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); text_size = png_sizeof(msg) > text_size ? text_size : png_sizeof(msg); - png_memcpy(text + prefix_size, msg, text_size + 1); + png_memcpy(text + prefix_size, msg, text_size); break; } if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) { @@ -1392,9 +1392,9 @@ * from the info_ptr struct. */ if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { 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) { png_warning(png_ptr, "Incorrect bKGD chunk index value"); @@ -1791,9 +1791,9 @@ } #else #ifdef PNG_FIXED_POINT_SUPPORTED 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"); return; } @@ -2248,11 +2248,11 @@ png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); } } -#else - png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); + else #endif + png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); png_free(png_ptr, png_ptr->unknown_chunk.data); png_ptr->unknown_chunk.data = NULL; } else diff -ru4N libpng-1.2.24/pngset.c libpng-1.2.25rc02/pngset.c --- libpng-1.2.24/pngset.c 2008-01-09 10:52:34.403912000 -0600 +++ libpng-1.2.25rc02/pngset.c 2008-02-10 15:28:41.218055000 -0600 @@ -1,10 +1,10 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.2.24 [December 14, 2007] + * Last changed in libpng 1.2.25 [February 10, 2008] * 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.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * The functions here are used during reads to store data from the file @@ -487,8 +487,9 @@ if (info_ptr->scal_s_width == NULL) { png_warning(png_ptr, "Memory allocation failed while processing sCAL."); + return; } png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); length = png_strlen(sheight) + 1; @@ -498,11 +499,11 @@ { png_free (png_ptr, info_ptr->scal_s_width); png_warning(png_ptr, "Memory allocation failed while processing sCAL."); + return; } png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); - info_ptr->valid |= PNG_INFO_sCAL; #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_SCAL; #endif @@ -982,8 +983,9 @@ if (to->name == NULL) { png_warning(png_ptr, "Out of memory while processing sPLT chunk"); + continue; } png_memcpy(to->name, from->name, length); to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, from->nentries * png_sizeof(png_sPLT_entry)); @@ -992,8 +994,9 @@ png_warning(png_ptr, "Out of memory while processing sPLT chunk"); png_free(png_ptr,to->name); to->name = NULL; + continue; } png_memcpy(to->entries, from->entries, from->nentries * png_sizeof(png_sPLT_entry)); to->nentries = from->nentries; diff -ru4N libpng-1.2.24/pngwrite.c libpng-1.2.25rc02/pngwrite.c --- libpng-1.2.24/pngwrite.c 2008-01-09 10:56:29.964328000 -0600 +++ libpng-1.2.25rc02/pngwrite.c 2008-02-10 15:28:41.422200000 -0600 @@ -1,10 +1,10 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.2.24 [December 14, 2007] + * Last changed in libpng 1.2.25 [February 10, 2008] * 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.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ @@ -481,14 +481,17 @@ png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); #endif /* PNG_USER_MEM_SUPPORTED */ png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - i=0; - do + if(user_png_ver) { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (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++]); + } if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) { /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so @@ -999,23 +1002,34 @@ mem_ptr = png_ptr->mem_ptr; #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) info_ptr = *info_ptr_ptr; 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 (png_ptr->num_chunk_list) - { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; - } + if (png_ptr->num_chunk_list) + { + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list=NULL; + png_ptr->num_chunk_list=0; + } #endif + } #ifdef PNG_USER_MEM_SUPPORTED png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, (png_voidp)mem_ptr);