mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng15] Fixes for multiple calls to png_read_update_info.
These fixes attend to most of the errors revealed in pngvalid, however doing the gamma work twice results in inaccuracies that can't be easily fixed. There is now a warning in the code if this is going to happen.
This commit is contained in:
committed by
Glenn Randers-Pehrson
parent
5c1905caae
commit
07772cba07
49
pngread.c
49
pngread.c
@@ -1032,6 +1032,10 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
|
||||
if (end_info_ptr != NULL)
|
||||
png_info_destroy(png_ptr, end_info_ptr);
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_destroy_gamma_table(png_ptr);
|
||||
#endif
|
||||
|
||||
png_free(png_ptr, png_ptr->zbuf);
|
||||
png_free(png_ptr, png_ptr->big_row_buf);
|
||||
png_free(png_ptr, png_ptr->prev_row);
|
||||
@@ -1042,15 +1046,6 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
|
||||
png_free(png_ptr, png_ptr->quantize_index);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->gamma_table);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->gamma_from_1);
|
||||
png_free(png_ptr, png_ptr->gamma_to_1);
|
||||
#endif
|
||||
|
||||
if (png_ptr->free_me & PNG_FREE_PLTE)
|
||||
png_zfree(png_ptr, png_ptr->palette);
|
||||
png_ptr->free_me &= ~PNG_FREE_PLTE;
|
||||
@@ -1068,42 +1063,6 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
|
||||
png_ptr->free_me &= ~PNG_FREE_HIST;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
if (png_ptr->gamma_16_table != NULL)
|
||||
{
|
||||
int i;
|
||||
int istop = (1 << (8 - png_ptr->gamma_shift));
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_table[i]);
|
||||
}
|
||||
png_free(png_ptr, png_ptr->gamma_16_table);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
if (png_ptr->gamma_16_from_1 != NULL)
|
||||
{
|
||||
int i;
|
||||
int istop = (1 << (8 - png_ptr->gamma_shift));
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
|
||||
}
|
||||
png_free(png_ptr, png_ptr->gamma_16_from_1);
|
||||
}
|
||||
if (png_ptr->gamma_16_to_1 != NULL)
|
||||
{
|
||||
int i;
|
||||
int istop = (1 << (8 - png_ptr->gamma_shift));
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
|
||||
}
|
||||
png_free(png_ptr, png_ptr->gamma_16_to_1);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
inflateEnd(&png_ptr->zstream);
|
||||
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
|
||||
Reference in New Issue
Block a user