Godot Engine – Multi-platform 2D and 3D game engine
libpng: Update to 1.6.59
Rémi Verschelde138cd7265de2
diff --git a/thirdparty/README.md b/thirdparty/README.mdindex c8db0d10ef7..cf914843241 100644--- a/thirdparty/README.md+++ b/thirdparty/README.md@@ -604,7 +604,7 @@ Files extracted from upstream source:## libpng- Upstream: http://libpng.org/pub/png/libpng.html-- Version: 1.6.58 (3061454d980de7d53608f594194cfac722721d2a, 2026)+- Version: 1.6.59 (cd952f49f95bb27154ae77dbb103032d95f6e580, 2026)- License: libpng/zlibFiles extracted from upstream source:diff --git a/thirdparty/libpng/png.c b/thirdparty/libpng/png.cindex cebe7af1f80..68cfc42e896 100644--- a/thirdparty/libpng/png.c+++ b/thirdparty/libpng/png.c@@ -13,7 +13,7 @@#include "pngpriv.h"/* Generate a compiler error if there is an old png.h in the search path. */-typedef png_libpng_version_1_6_58 Your_png_h_is_not_version_1_6_58;+typedef png_libpng_version_1_6_59 Your_png_h_is_not_version_1_6_59;/* Sanity check the chunks definitions - PNG_KNOWN_CHUNKS from pngpriv.h and the* corresponding macro definitions. This causes a compile time failure if@@ -820,7 +820,7 @@ png_get_copyright(png_const_structrp png_ptr)return PNG_STRING_COPYRIGHT#elsereturn PNG_STRING_NEWLINE \- "libpng version 1.6.58" PNG_STRING_NEWLINE \+ "libpng version 1.6.59" PNG_STRING_NEWLINE \"Copyright (c) 2018-2026 Cosmin Truta" PNG_STRING_NEWLINE \"Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \PNG_STRING_NEWLINE \diff --git a/thirdparty/libpng/png.h b/thirdparty/libpng/png.hindex 1d98cc53e1d..70e6eaebfd9 100644--- a/thirdparty/libpng/png.h+++ b/thirdparty/libpng/png.h@@ -1,6 +1,6 @@/* png.h - header file for PNG reference library*- * libpng version 1.6.58+ * libpng version 1.6.59** Copyright (c) 2018-2026 Cosmin Truta* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson@@ -14,7 +14,7 @@* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger* libpng versions 0.97, January 1998, through 1.6.35, July 2018:* Glenn Randers-Pehrson- * libpng versions 1.6.36, December 2018, through 1.6.58, April 2026:+ * libpng versions 1.6.36, December 2018, through 1.6.59, September 2026:* Cosmin Truta* See also "Contributing Authors", below.*/@@ -238,7 +238,7 @@* ...* 1.5.30 15 10530 15.so.15.30[.0]* ...- * 1.6.58 16 10658 16.so.16.58[.0]+ * 1.6.59 16 10659 16.so.16.59[.0]** Henceforth the source version will match the shared-library major and* minor numbers; the shared-library major version number will be used for@@ -274,7 +274,7 @@*//* Version information for png.h - this should match the version in png.c */-#define PNG_LIBPNG_VER_STRING "1.6.58"+#define PNG_LIBPNG_VER_STRING "1.6.59"#define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n"/* The versions of shared library builds should stay in sync, going forward */@@ -285,7 +285,7 @@/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */#define PNG_LIBPNG_VER_MAJOR 1#define PNG_LIBPNG_VER_MINOR 6-#define PNG_LIBPNG_VER_RELEASE 58+#define PNG_LIBPNG_VER_RELEASE 59/* This should be zero for a public release, or non-zero for a* development version.@@ -316,7 +316,7 @@* From version 1.0.1 it is:* XXYYZZ, where XX=major, YY=minor, ZZ=release*/-#define PNG_LIBPNG_VER 10658 /* 1.6.58 */+#define PNG_LIBPNG_VER 10659 /* 1.6.59 *//* Library configuration: these options cannot be changed after* the library has been built.@@ -426,7 +426,7 @@ extern "C" {/* This triggers a compiler error in png.c, if png.c and png.h* do not agree upon the version number.*/-typedef char *png_libpng_version_1_6_58;+typedef char *png_libpng_version_1_6_59;/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.*diff --git a/thirdparty/libpng/pngconf.h b/thirdparty/libpng/pngconf.hindex 3eda9d047bd..3f4aaa50948 100644--- a/thirdparty/libpng/pngconf.h+++ b/thirdparty/libpng/pngconf.h@@ -1,6 +1,6 @@/* pngconf.h - machine-configurable file for libpng*- * libpng version 1.6.58+ * libpng version 1.6.59** Copyright (c) 2018-2026 Cosmin Truta* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrsondiff --git a/thirdparty/libpng/pnglibconf.h b/thirdparty/libpng/pnglibconf.hindex 435c752c2a3..d72287a8409 100644--- a/thirdparty/libpng/pnglibconf.h+++ b/thirdparty/libpng/pnglibconf.h@@ -1,6 +1,6 @@/* pnglibconf.h - library build configuration */-/* libpng version 1.6.58 */+/* libpng version 1.6.59 *//* Copyright (c) 2018-2026 Cosmin Truta *//* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */diff --git a/thirdparty/libpng/pngread.c b/thirdparty/libpng/pngread.cindex 24199689a76..0033089ad83 100644--- a/thirdparty/libpng/pngread.c+++ b/thirdparty/libpng/pngread.c@@ -682,8 +682,10 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)if (png_ptr == NULL)return;- /* If png_read_end is called in the middle of reading the rows there may- * still be pending IDAT data and an owned zstream. Deal with this here.+ /* If png_read_end is called in the middle of reading the rows,+ * there may still be pending IDAT data and an owned zstream.+ * If it is called before row reading starts, there is pending+ * IDAT data but no owned zstream.*/#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTEDif (png_chunk_unknown_handling(png_ptr, png_IDAT) == 0)diff --git a/thirdparty/libpng/pngrtran.c b/thirdparty/libpng/pngrtran.cindex 0ac8df749e9..28e6127c370 100644--- a/thirdparty/libpng/pngrtran.c+++ b/thirdparty/libpng/pngrtran.c@@ -514,6 +514,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,* this function more than once per png_struct.*/png_free(png_ptr, png_ptr->quantize_index);+ png_ptr->quantize_index = NULL;png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,PNG_MAX_PALETTE_LENGTH);for (i = 0; i < PNG_MAX_PALETTE_LENGTH; i++)diff --git a/thirdparty/libpng/pngrutil.c b/thirdparty/libpng/pngrutil.cindex 3a35fe9de2d..482f0ae8dfd 100644--- a/thirdparty/libpng/pngrutil.c+++ b/thirdparty/libpng/pngrutil.c@@ -405,6 +405,18 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size)}#endif /* READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|eXIf|SEQUENTIAL_READ */+/* Detach the zstream from the input and output buffers left by+ * the current or a previous owner, and possibly deallocated since.+ */+static void+png_inflate_detach_buffers(png_structrp png_ptr)+{+ png_ptr->zstream.next_in = NULL;+ png_ptr->zstream.avail_in = 0;+ png_ptr->zstream.next_out = NULL;+ png_ptr->zstream.avail_out = 0;+}+/* png_inflate_claim: claim the zstream for some nefarious purpose that involves* decompression. Returns Z_OK on success, else a zlib error code. It checks* the owner but, in final release builds, just issues a warning if some other@@ -465,13 +477,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)#endif /* ZLIB_VERNUM >= 0x1240 */- /* Set this for safety, just in case the previous owner left pointers to- * memory allocations.- */- png_ptr->zstream.next_in = NULL;- png_ptr->zstream.avail_in = 0;- png_ptr->zstream.next_out = NULL;- png_ptr->zstream.avail_out = 0;+ png_inflate_detach_buffers(png_ptr);if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0){@@ -808,7 +814,8 @@ png_decompress_chunk(png_structrp png_ptr,else if (ret == Z_OK)ret = PNG_UNEXPECTED_ZLIB_RETURN;- /* Release the claimed stream */+ /* Release the claimed stream. */+ png_inflate_detach_buffers(png_ptr);png_ptr->zowner = 0;}@@ -1491,6 +1498,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)if (errmsg == NULL){+ png_inflate_detach_buffers(png_ptr);png_ptr->zowner = 0;return handled_ok;}@@ -1517,7 +1525,8 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)else /* profile truncated */errmsg = png_ptr->zstream.msg;- /* Release the stream */+ /* Release the claimed stream. */+ png_inflate_detach_buffers(png_ptr);png_ptr->zowner = 0;}@@ -3062,7 +3071,7 @@ read_chunks[PNG_INDEX_unknown] =# define CDiTXt NoCheck, 6U, 0, hIHDR, 1/* Allocates 'length+1'; checked in the handler */# define CDbKGD 6U, 1U, hIDAT, hIHDR, 0-# define CDhIST 1024U, 0U, hPLTE, hIHDR, 0+# define CDhIST 1024U, 0U, hIDAT, hPLTE, 0# define CDpHYs 9U, 9U, hIDAT, hIHDR, 0# define CDsPLT NoCheck, 3U, hIDAT, hIHDR, 1/* Allocates 'length+1'; checked in the handler */@@ -4337,11 +4346,7 @@ png_read_finish_IDAT(png_structrp png_ptr)*/if (png_ptr->zowner == png_IDAT){- /* Always do this; the pointers otherwise point into the read buffer. */- png_ptr->zstream.next_in = NULL;- png_ptr->zstream.avail_in = 0;-- /* Now we no longer own the zstream. */+ png_inflate_detach_buffers(png_ptr);png_ptr->zowner = 0;/* The slightly weird semantics of the sequential IDAT reading is that we@@ -4604,6 +4609,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED){png_free(png_ptr, png_ptr->big_row_buf);png_free(png_ptr, png_ptr->big_prev_row);+ png_ptr->big_row_buf = png_ptr->big_prev_row = NULL;if (png_ptr->interlaced != 0)png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr,diff --git a/thirdparty/libpng/pngset.c b/thirdparty/libpng/pngset.cindex 513c51eb4a8..f86af0f0177 100644--- a/thirdparty/libpng/pngset.c+++ b/thirdparty/libpng/pngset.c@@ -811,6 +811,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,* regardless of num_palette.*/png_free(png_ptr, png_ptr->palette);+ png_ptr->palette = NULL;png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));info_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,@@ -1223,6 +1224,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,* functions (e.g. png_do_expand_palette).*/png_free(png_ptr, png_ptr->trans_alpha);+ png_ptr->trans_alpha = NULL;png_ptr->trans_alpha = png_voidcast(png_bytep,png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));memset(png_ptr->trans_alpha, 0xff, PNG_MAX_PALETTE_LENGTH);