mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Make png_struct palette, trans_alpha private
This removes the side-effect on the png_struct palette of calling png_set_PLTE or png_set_tRNS. NOTE: this is a quiet API change, it was possible before to alter the palette on a PNG image by using png_set_PLTE, but this was unintended and inconsistent with the other png_set APIs. Fix a bug in palette index checking; png_struct::num_palette could, in principle, get changed by the transformations (e.g. png_set_quantize) and this would invalidate the check. The palette checking init function now makes a copy of png_struct::num_palette. Fix a bug in pngvalid error handling. A png_error in png_write_info is not continuable (a valid image cannot necessarily be written afterward) because the png_error aborts the write of subsequent pre-IDAT chunks. In particular an abort as a result of a bogus colorspace information (gAMA, cHRM, sBIT etc) prevents the write of the PLTE chunk. Signed-off-by: John Bowler <jbowler@acm.org>
This commit is contained in:
@@ -727,22 +727,20 @@ png_read_destroy(png_structrp png_ptr)
|
||||
png_free(png_ptr, png_ptr->read_buffer);
|
||||
png_ptr->read_buffer = NULL;
|
||||
|
||||
if ((png_ptr->free_me & PNG_FREE_PLTE) != 0)
|
||||
if (png_ptr->palette != NULL)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->palette);
|
||||
png_ptr->num_palette = 0;
|
||||
png_ptr->palette = NULL;
|
||||
}
|
||||
png_ptr->free_me &= PNG_BIC_MASK(PNG_FREE_PLTE);
|
||||
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
if ((png_ptr->free_me & PNG_FREE_TRNS) != 0)
|
||||
if (png_ptr->trans_alpha != NULL)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->trans_alpha);
|
||||
png_ptr->num_trans = 0;
|
||||
png_ptr->trans_alpha = NULL;
|
||||
}
|
||||
png_ptr->free_me &= PNG_BIC_MASK(PNG_FREE_TRNS);
|
||||
#endif
|
||||
|
||||
if (png_ptr->zstream.state != NULL)
|
||||
|
||||
Reference in New Issue
Block a user