mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Allow fine grain control of unknown chunk APIs. This change allows
png_set_keep_unknown_chunks() to be turned off if not required and causes both read and write to behave appropriately (on read this is only possible if the user callback is used to handle unknown chunks). The change also removes the support for storing unknown chunks in the info_struct if the only unknown handling enabled is via the callback, allowing libpng to be configured with callback reading and none of the unnecessary code.
This commit is contained in:
committed by
Glenn Randers-Pehrson
parent
025d415838
commit
4a6c6df6c7
23
pngset.c
23
pngset.c
@@ -1111,6 +1111,29 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0)
|
||||
return;
|
||||
|
||||
/* Check for the failure cases where support has been disabled at compile
|
||||
* time. This code is hardly ever compiled - it's here because
|
||||
* STORE_UNKNOWN_CHUNKS is set by both read and write code (compiling in this
|
||||
* code) but may be meaningless if the read or write handling of unknown
|
||||
* chunks is not compiled in.
|
||||
*/
|
||||
# if !(defined PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
(defined PNG_READ_SUPPORTED)
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on read");
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
# if !(defined PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
(defined PNG_WRITE_SUPPORTED)
|
||||
if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on write");
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Prior to 1.6.0 this code used png_malloc_warn, however this meant that
|
||||
* unknown critical chunks could be lost with just a warning resulting in
|
||||
* undefined behavior. Changing to png_malloc fixes this by producing a
|
||||
|
||||
Reference in New Issue
Block a user