Skip to content

Commit 42910d0

Browse files
authored
Update libpng to 1.6.51 (#2900)
1 parent 8924a63 commit 42910d0

File tree

12 files changed

+183
-201
lines changed

12 files changed

+183
-201
lines changed

3rdparty/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190

191191
## png
192192
- [![Upstream](https://img.shields.io/github/v/tag/glennrp/libpng?label=Upstream)](https://github.com/glennrp/libpng)
193-
- Version: 1.6.50
193+
- Version: 1.6.51
194194
- License: PNG Reference Library License version 2
195195

196196
## poly2tri

3rdparty/png/png.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "pngpriv.h"
1414

1515
/* Generate a compiler error if there is an old png.h in the search path. */
16-
typedef png_libpng_version_1_6_50 Your_png_h_is_not_version_1_6_50;
16+
typedef png_libpng_version_1_6_51 Your_png_h_is_not_version_1_6_51;
1717

1818
/* Sanity check the chunks definitions - PNG_KNOWN_CHUNKS from pngpriv.h and the
1919
* corresponding macro definitions. This causes a compile time failure if
@@ -108,10 +108,16 @@ png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED)
108108
if (png_ptr == NULL)
109109
return NULL;
110110

111-
if (items >= (~(png_alloc_size_t)0)/size)
111+
/* This check against overflow is vestigial, dating back from
112+
* the old times when png_zalloc used to be an exported function.
113+
* We're still keeping it here for now, as an extra-cautious
114+
* prevention against programming errors inside zlib, although it
115+
* should rather be a debug-time assertion instead.
116+
*/
117+
if (size != 0 && items >= (~(png_alloc_size_t)0) / size)
112118
{
113-
png_warning (png_voidcast(png_structrp, png_ptr),
114-
"Potential overflow in png_zalloc()");
119+
png_warning(png_voidcast(png_structrp, png_ptr),
120+
"Potential overflow in png_zalloc()");
115121
return NULL;
116122
}
117123

@@ -238,10 +244,6 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
238244
png_warning(png_ptr, m);
239245
#endif
240246

241-
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
242-
png_ptr->flags = 0;
243-
#endif
244-
245247
return 0;
246248
}
247249

@@ -815,7 +817,7 @@ png_get_copyright(png_const_structrp png_ptr)
815817
return PNG_STRING_COPYRIGHT
816818
#else
817819
return PNG_STRING_NEWLINE \
818-
"libpng version 1.6.50" PNG_STRING_NEWLINE \
820+
"libpng version 1.6.51" PNG_STRING_NEWLINE \
819821
"Copyright (c) 2018-2025 Cosmin Truta" PNG_STRING_NEWLINE \
820822
"Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
821823
PNG_STRING_NEWLINE \

3rdparty/png/png.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* png.h - header file for PNG reference library
22
*
3-
* libpng version 1.6.50
3+
* libpng version 1.6.51
44
*
55
* Copyright (c) 2018-2025 Cosmin Truta
66
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
@@ -14,7 +14,7 @@
1414
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
1515
* libpng versions 0.97, January 1998, through 1.6.35, July 2018:
1616
* Glenn Randers-Pehrson
17-
* libpng versions 1.6.36, December 2018, through 1.6.50, July 2025:
17+
* libpng versions 1.6.36, December 2018, through 1.6.51, November 2025:
1818
* Cosmin Truta
1919
* See also "Contributing Authors", below.
2020
*/
@@ -238,7 +238,7 @@
238238
* ...
239239
* 1.5.30 15 10530 15.so.15.30[.0]
240240
* ...
241-
* 1.6.50 16 10650 16.so.16.50[.0]
241+
* 1.6.51 16 10651 16.so.16.51[.0]
242242
*
243243
* Henceforth the source version will match the shared-library major and
244244
* minor numbers; the shared-library major version number will be used for
@@ -274,7 +274,7 @@
274274
*/
275275

276276
/* Version information for png.h - this should match the version in png.c */
277-
#define PNG_LIBPNG_VER_STRING "1.6.50"
277+
#define PNG_LIBPNG_VER_STRING "1.6.51"
278278
#define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n"
279279

280280
/* The versions of shared library builds should stay in sync, going forward */
@@ -285,7 +285,7 @@
285285
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
286286
#define PNG_LIBPNG_VER_MAJOR 1
287287
#define PNG_LIBPNG_VER_MINOR 6
288-
#define PNG_LIBPNG_VER_RELEASE 50
288+
#define PNG_LIBPNG_VER_RELEASE 51
289289

290290
/* This should be zero for a public release, or non-zero for a
291291
* development version.
@@ -316,7 +316,7 @@
316316
* From version 1.0.1 it is:
317317
* XXYYZZ, where XX=major, YY=minor, ZZ=release
318318
*/
319-
#define PNG_LIBPNG_VER 10650 /* 1.6.50 */
319+
#define PNG_LIBPNG_VER 10651 /* 1.6.51 */
320320

321321
/* Library configuration: these options cannot be changed after
322322
* the library has been built.
@@ -426,7 +426,7 @@ extern "C" {
426426
/* This triggers a compiler error in png.c, if png.c and png.h
427427
* do not agree upon the version number.
428428
*/
429-
typedef char* png_libpng_version_1_6_50;
429+
typedef char* png_libpng_version_1_6_51;
430430

431431
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
432432
*

3rdparty/png/pngconf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* pngconf.h - machine-configurable file for libpng
22
*
3-
* libpng version 1.6.50
3+
* libpng version 1.6.51
44
*
55
* Copyright (c) 2018-2025 Cosmin Truta
66
* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson

3rdparty/png/pngdebug.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
#define PNGDEBUG_H
3939
/* These settings control the formatting of messages in png.c and pngerror.c */
4040
/* Moved to pngdebug.h at 1.5.0 */
41-
# ifndef PNG_LITERAL_SHARP
42-
# define PNG_LITERAL_SHARP 0x23
43-
# endif
4441
# ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
4542
# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
4643
# endif

3rdparty/png/pngerror.c

Lines changed: 7 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,6 @@ PNG_FUNCTION(void,PNGAPI
3939
png_error,(png_const_structrp png_ptr, png_const_charp error_message),
4040
PNG_NORETURN)
4141
{
42-
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
43-
char msg[16];
44-
if (png_ptr != NULL)
45-
{
46-
if ((png_ptr->flags &
47-
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
48-
{
49-
if (*error_message == PNG_LITERAL_SHARP)
50-
{
51-
/* Strip "#nnnn " from beginning of error message. */
52-
int offset;
53-
for (offset = 1; offset<15; offset++)
54-
if (error_message[offset] == ' ')
55-
break;
56-
57-
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
58-
{
59-
int i;
60-
for (i = 0; i < offset - 1; i++)
61-
msg[i] = error_message[i + 1];
62-
msg[i - 1] = '\0';
63-
error_message = msg;
64-
}
65-
66-
else
67-
error_message += offset;
68-
}
69-
70-
else
71-
{
72-
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
73-
{
74-
msg[0] = '0';
75-
msg[1] = '\0';
76-
error_message = msg;
77-
}
78-
}
79-
}
80-
}
81-
#endif
8242
if (png_ptr != NULL && png_ptr->error_fn != NULL)
8343
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
8444
error_message);
@@ -216,21 +176,6 @@ void PNGAPI
216176
png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
217177
{
218178
int offset = 0;
219-
if (png_ptr != NULL)
220-
{
221-
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
222-
if ((png_ptr->flags &
223-
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
224-
#endif
225-
{
226-
if (*warning_message == PNG_LITERAL_SHARP)
227-
{
228-
for (offset = 1; offset < 15; offset++)
229-
if (warning_message[offset] == ' ')
230-
break;
231-
}
232-
}
233-
}
234179
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
235180
(*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
236181
warning_message + offset);
@@ -712,42 +657,9 @@ png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
712657
PNG_NORETURN)
713658
{
714659
#ifdef PNG_CONSOLE_IO_SUPPORTED
715-
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
716-
/* Check on NULL only added in 1.5.4 */
717-
if (error_message != NULL && *error_message == PNG_LITERAL_SHARP)
718-
{
719-
/* Strip "#nnnn " from beginning of error message. */
720-
int offset;
721-
char error_number[16];
722-
for (offset = 0; offset<15; offset++)
723-
{
724-
error_number[offset] = error_message[offset + 1];
725-
if (error_message[offset] == ' ')
726-
break;
727-
}
728-
729-
if ((offset > 1) && (offset < 15))
730-
{
731-
error_number[offset - 1] = '\0';
732-
fprintf(stderr, "libpng error no. %s: %s",
733-
error_number, error_message + offset + 1);
734-
fprintf(stderr, PNG_STRING_NEWLINE);
735-
}
736-
737-
else
738-
{
739-
fprintf(stderr, "libpng error: %s, offset=%d",
740-
error_message, offset);
741-
fprintf(stderr, PNG_STRING_NEWLINE);
742-
}
743-
}
744-
else
745-
#endif
746-
{
747-
fprintf(stderr, "libpng error: %s", error_message ? error_message :
748-
"undefined");
749-
fprintf(stderr, PNG_STRING_NEWLINE);
750-
}
660+
fprintf(stderr, "libpng error: %s", error_message ? error_message :
661+
"undefined");
662+
fprintf(stderr, PNG_STRING_NEWLINE);
751663
#else
752664
PNG_UNUSED(error_message) /* Make compiler happy */
753665
#endif
@@ -785,40 +697,8 @@ static void /* PRIVATE */
785697
png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
786698
{
787699
#ifdef PNG_CONSOLE_IO_SUPPORTED
788-
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
789-
if (*warning_message == PNG_LITERAL_SHARP)
790-
{
791-
int offset;
792-
char warning_number[16];
793-
for (offset = 0; offset < 15; offset++)
794-
{
795-
warning_number[offset] = warning_message[offset + 1];
796-
if (warning_message[offset] == ' ')
797-
break;
798-
}
799-
800-
if ((offset > 1) && (offset < 15))
801-
{
802-
warning_number[offset + 1] = '\0';
803-
fprintf(stderr, "libpng warning no. %s: %s",
804-
warning_number, warning_message + offset);
805-
fprintf(stderr, PNG_STRING_NEWLINE);
806-
}
807-
808-
else
809-
{
810-
fprintf(stderr, "libpng warning: %s",
811-
warning_message);
812-
fprintf(stderr, PNG_STRING_NEWLINE);
813-
}
814-
}
815-
else
816-
# endif
817-
818-
{
819-
fprintf(stderr, "libpng warning: %s", warning_message);
820-
fprintf(stderr, PNG_STRING_NEWLINE);
821-
}
700+
fprintf(stderr, "libpng warning: %s", warning_message);
701+
fprintf(stderr, PNG_STRING_NEWLINE);
822702
#else
823703
PNG_UNUSED(warning_message) /* Make compiler happy */
824704
#endif
@@ -866,12 +746,8 @@ png_get_error_ptr(png_const_structrp png_ptr)
866746
void PNGAPI
867747
png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
868748
{
869-
if (png_ptr != NULL)
870-
{
871-
png_ptr->flags &=
872-
((~(PNG_FLAG_STRIP_ERROR_NUMBERS |
873-
PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
874-
}
749+
PNG_UNUSED(png_ptr)
750+
PNG_UNUSED(strip_mode)
875751
}
876752
#endif
877753

3rdparty/png/pnglibconf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* pnglibconf.h - library build configuration */
22

3-
/* libpng version 1.6.50 */
3+
/* libpng version 1.6.51 */
44

55
/* Copyright (c) 2018-2025 Cosmin Truta */
66
/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */

3rdparty/png/pngpriv.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,15 @@
302302
# define PNG_LOONGARCH_LSX_IMPLEMENTATION 0
303303
#endif
304304

305-
#if PNG_RISCV_RVV_OPT > 0
305+
#if PNG_RISCV_RVV_OPT > 0 && __riscv_v >= 1000000
306306
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_rvv
307307
# ifndef PNG_RISCV_RVV_IMPLEMENTATION
308308
/* Use the intrinsics code by default. */
309309
# define PNG_RISCV_RVV_IMPLEMENTATION 1
310310
# endif
311311
#else
312312
# define PNG_RISCV_RVV_IMPLEMENTATION 0
313-
#endif
313+
#endif /* PNG_RISCV_RVV_OPT > 0 && __riscv_v >= 1000000 */
314314

315315
/* Is this a build of a DLL where compilation of the object modules requires
316316
* different preprocessor settings to those required for a simple library? If
@@ -710,7 +710,7 @@
710710
/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000U */
711711
/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000U */
712712
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000U
713-
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000U
713+
/* 0x40000U unused */
714714
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000U
715715
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000U /* Added to libpng-1.4.0 */
716716
#define PNG_FLAG_APP_WARNINGS_WARN 0x200000U /* Added to libpng-1.6.0 */
@@ -1546,7 +1546,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_lsx,(png_row_infop
15461546
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
15471547
#endif
15481548

1549-
#if PNG_RISCV_RVV_OPT > 0
1549+
#if PNG_RISCV_RVV_IMPLEMENTATION == 1
15501550
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_rvv,(png_row_infop
15511551
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
15521552
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_rvv,(png_row_infop
@@ -2175,7 +2175,7 @@ PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_lsx,
21752175
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
21762176
#endif
21772177

2178-
# if PNG_RISCV_RVV_OPT > 0
2178+
# if PNG_RISCV_RVV_IMPLEMENTATION == 1
21792179
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_rvv,
21802180
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
21812181
#endif

0 commit comments

Comments
 (0)