Skip to content

Commit f34b33c

Browse files
Chubercikakien-mga
authored andcommitted
libpng: Update to 1.6.43
(cherry picked from commit 41268d7)
1 parent 251e381 commit f34b33c

File tree

18 files changed

+407
-336
lines changed

18 files changed

+407
-336
lines changed

COPYRIGHT.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ License: BSD-3-clause
197197

198198
Files: ./thirdparty/libpng/
199199
Comment: libpng
200-
Copyright: 1995-2019, The PNG Reference Library Authors.
201-
2018-2019, Cosmin Truta.
200+
Copyright: 1995-2024, The PNG Reference Library Authors.
201+
2018-2024, Cosmin Truta.
202202
2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
203203
1996-1997, Andreas Dilger.
204204
1995-1996, Guy Eric Schalnat, Group 42, Inc.

thirdparty/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ Files extracted from upstream source:
178178
## libpng
179179

180180
- Upstream: http://libpng.org/pub/png/libpng.html
181-
- Version: 1.6.40 (f135775ad4e5d4408d2e12ffcc71bb36e6b48551, 2023)
181+
- Version: 1.6.43 (ed217e3e601d8e462f7fd1e04bed43ac42212429, 2024)
182182
- License: libpng/zlib
183183

184184
Files extracted from upstream source:
185185

186-
- all .c and .h files of the main directory, except from
187-
`example.c` and `pngtest.c`
188-
- the arm/ folder
186+
- All `.c` and `.h` files of the main directory, apart from `example.c` and
187+
`pngtest.c`
188+
- The `arm/` folder
189189
- `scripts/pnglibconf.h.prebuilt` as `pnglibconf.h`
190190
- `LICENSE`
191191

thirdparty/libpng/LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
44
PNG Reference Library License version 2
55
---------------------------------------
66

7-
* Copyright (c) 1995-2023 The PNG Reference Library Authors.
8-
* Copyright (c) 2018-2023 Cosmin Truta.
7+
* Copyright (c) 1995-2024 The PNG Reference Library Authors.
8+
* Copyright (c) 2018-2024 Cosmin Truta.
99
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
1010
* Copyright (c) 1996-1997 Andreas Dilger.
1111
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.

thirdparty/libpng/png.c

Lines changed: 31 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/* png.c - location for general purpose libpng functions
33
*
4-
* Copyright (c) 2018-2023 Cosmin Truta
4+
* Copyright (c) 2018-2024 Cosmin Truta
55
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
66
* Copyright (c) 1996-1997 Andreas Dilger
77
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -14,27 +14,7 @@
1414
#include "pngpriv.h"
1515

1616
/* Generate a compiler error if there is an old png.h in the search path. */
17-
typedef png_libpng_version_1_6_40 Your_png_h_is_not_version_1_6_40;
18-
19-
#ifdef __GNUC__
20-
/* The version tests may need to be added to, but the problem warning has
21-
* consistently been fixed in GCC versions which obtain wide-spread release.
22-
* The problem is that many versions of GCC rearrange comparison expressions in
23-
* the optimizer in such a way that the results of the comparison will change
24-
* if signed integer overflow occurs. Such comparisons are not permitted in
25-
* ANSI C90, however GCC isn't clever enough to work out that that do not occur
26-
* below in png_ascii_from_fp and png_muldiv, so it produces a warning with
27-
* -Wextra. Unfortunately this is highly dependent on the optimizer and the
28-
* machine architecture so the warning comes and goes unpredictably and is
29-
* impossible to "fix", even were that a good idea.
30-
*/
31-
#if __GNUC__ == 7 && __GNUC_MINOR__ == 1
32-
#define GCC_STRICT_OVERFLOW 1
33-
#endif /* GNU 7.1.x */
34-
#endif /* GNU */
35-
#ifndef GCC_STRICT_OVERFLOW
36-
#define GCC_STRICT_OVERFLOW 0
37-
#endif
17+
typedef png_libpng_version_1_6_43 Your_png_h_is_not_version_1_6_43;
3818

3919
/* Tells libpng that we have already handled the first "num_bytes" bytes
4020
* of the PNG file signature. If the PNG data is embedded into another
@@ -73,21 +53,21 @@ png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
7353
int PNGAPI
7454
png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check)
7555
{
76-
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
56+
static const png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
7757

7858
if (num_to_check > 8)
7959
num_to_check = 8;
8060

8161
else if (num_to_check < 1)
82-
return (-1);
62+
return -1;
8363

8464
if (start > 7)
85-
return (-1);
65+
return -1;
8666

8767
if (start + num_to_check > 8)
8868
num_to_check = 8 - start;
8969

90-
return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check)));
70+
return memcmp(&sig[start], &png_signature[start], num_to_check);
9171
}
9272

9373
#endif /* READ */
@@ -447,7 +427,6 @@ png_info_init_3,(png_infopp ptr_ptr, size_t png_info_struct_size),
447427
memset(info_ptr, 0, (sizeof *info_ptr));
448428
}
449429

450-
/* The following API is not called internally */
451430
void PNGAPI
452431
png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr,
453432
int freer, png_uint_32 mask)
@@ -686,9 +665,9 @@ png_voidp PNGAPI
686665
png_get_io_ptr(png_const_structrp png_ptr)
687666
{
688667
if (png_ptr == NULL)
689-
return (NULL);
668+
return NULL;
690669

691-
return (png_ptr->io_ptr);
670+
return png_ptr->io_ptr;
692671
}
693672

694673
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
@@ -752,7 +731,7 @@ png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
752731

753732
{
754733
size_t pos = 0;
755-
char number_buf[5]; /* enough for a four-digit year */
734+
char number_buf[5] = {0, 0, 0, 0, 0}; /* enough for a four-digit year */
756735

757736
# define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string))
758737
# define APPEND_NUMBER(format, value)\
@@ -815,8 +794,8 @@ png_get_copyright(png_const_structrp png_ptr)
815794
return PNG_STRING_COPYRIGHT
816795
#else
817796
return PNG_STRING_NEWLINE \
818-
"libpng version 1.6.40" PNG_STRING_NEWLINE \
819-
"Copyright (c) 2018-2023 Cosmin Truta" PNG_STRING_NEWLINE \
797+
"libpng version 1.6.43" PNG_STRING_NEWLINE \
798+
"Copyright (c) 2018-2024 Cosmin Truta" PNG_STRING_NEWLINE \
820799
"Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
821800
PNG_STRING_NEWLINE \
822801
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
@@ -977,7 +956,7 @@ png_reset_zstream(png_structrp png_ptr)
977956
return Z_STREAM_ERROR;
978957

979958
/* WARNING: this resets the window bits to the maximum! */
980-
return (inflateReset(&png_ptr->zstream));
959+
return inflateReset(&png_ptr->zstream);
981960
}
982961
#endif /* READ */
983962

@@ -986,7 +965,7 @@ png_uint_32 PNGAPI
986965
png_access_version_number(void)
987966
{
988967
/* Version of *.c files used when building libpng */
989-
return((png_uint_32)PNG_LIBPNG_VER);
968+
return (png_uint_32)PNG_LIBPNG_VER;
990969
}
991970

992971
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
@@ -1842,14 +1821,14 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
18421821
}
18431822
# ifdef PNG_WARNINGS_SUPPORTED
18441823
else
1845-
{
1846-
char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114 */
1824+
{
1825+
char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114 */
18471826

1848-
pos = png_safecat(message, (sizeof message), pos,
1849-
png_format_number(number, number+(sizeof number),
1850-
PNG_NUMBER_FORMAT_x, value));
1851-
pos = png_safecat(message, (sizeof message), pos, "h: "); /* +2 = 116 */
1852-
}
1827+
pos = png_safecat(message, (sizeof message), pos,
1828+
png_format_number(number, number+(sizeof number),
1829+
PNG_NUMBER_FORMAT_x, value));
1830+
pos = png_safecat(message, (sizeof message), pos, "h: "); /* +2 = 116 */
1831+
}
18531832
# endif
18541833
/* The 'reason' is an arbitrary message, allow +79 maximum 195 */
18551834
pos = png_safecat(message, (sizeof message), pos, reason);
@@ -2532,17 +2511,6 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
25322511

25332512
#endif /* COLORSPACE */
25342513

2535-
#ifdef __GNUC__
2536-
/* This exists solely to work round a warning from GNU C. */
2537-
static int /* PRIVATE */
2538-
png_gt(size_t a, size_t b)
2539-
{
2540-
return a > b;
2541-
}
2542-
#else
2543-
# define png_gt(a,b) ((a) > (b))
2544-
#endif
2545-
25462514
void /* PRIVATE */
25472515
png_check_IHDR(png_const_structrp png_ptr,
25482516
png_uint_32 width, png_uint_32 height, int bit_depth,
@@ -2564,8 +2532,16 @@ png_check_IHDR(png_const_structrp png_ptr,
25642532
error = 1;
25652533
}
25662534

2567-
if (png_gt(((width + 7) & (~7U)),
2568-
((PNG_SIZE_MAX
2535+
/* The bit mask on the first line below must be at least as big as a
2536+
* png_uint_32. "~7U" is not adequate on 16-bit systems because it will
2537+
* be an unsigned 16-bit value. Casting to (png_alloc_size_t) makes the
2538+
* type of the result at least as bit (in bits) as the RHS of the > operator
2539+
* which also avoids a common warning on 64-bit systems that the comparison
2540+
* of (png_uint_32) against the constant value on the RHS will always be
2541+
* false.
2542+
*/
2543+
if (((width + 7) & ~(png_alloc_size_t)7) >
2544+
(((PNG_SIZE_MAX
25692545
- 48 /* big_row_buf hack */
25702546
- 1) /* filter byte */
25712547
/ 8) /* 8-byte RGBA pixels */
@@ -2891,14 +2867,6 @@ png_pow10(int power)
28912867
/* Function to format a floating point value in ASCII with a given
28922868
* precision.
28932869
*/
2894-
#if GCC_STRICT_OVERFLOW
2895-
#pragma GCC diagnostic push
2896-
/* The problem arises below with exp_b10, which can never overflow because it
2897-
* comes, originally, from frexp and is therefore limited to a range which is
2898-
* typically +/-710 (log2(DBL_MAX)/log2(DBL_MIN)).
2899-
*/
2900-
#pragma GCC diagnostic warning "-Wstrict-overflow=2"
2901-
#endif /* GCC_STRICT_OVERFLOW */
29022870
void /* PRIVATE */
29032871
png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size,
29042872
double fp, unsigned int precision)
@@ -3220,10 +3188,6 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size,
32203188
/* Here on buffer too small. */
32213189
png_error(png_ptr, "ASCII conversion buffer too small");
32223190
}
3223-
#if GCC_STRICT_OVERFLOW
3224-
#pragma GCC diagnostic pop
3225-
#endif /* GCC_STRICT_OVERFLOW */
3226-
32273191
# endif /* FLOATING_POINT */
32283192

32293193
# ifdef PNG_FIXED_POINT_SUPPORTED
@@ -3251,7 +3215,7 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
32513215
if (num <= 0x80000000) /* else overflowed */
32523216
{
32533217
unsigned int ndigits = 0, first = 16 /* flag value */;
3254-
char digits[10];
3218+
char digits[10] = {0};
32553219

32563220
while (num)
32573221
{
@@ -3336,15 +3300,6 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
33363300
* the nearest .00001). Overflow and divide by zero are signalled in
33373301
* the result, a boolean - true on success, false on overflow.
33383302
*/
3339-
#if GCC_STRICT_OVERFLOW /* from above */
3340-
/* It is not obvious which comparison below gets optimized in such a way that
3341-
* signed overflow would change the result; looking through the code does not
3342-
* reveal any tests which have the form GCC complains about, so presumably the
3343-
* optimizer is moving an add or subtract into the 'if' somewhere.
3344-
*/
3345-
#pragma GCC diagnostic push
3346-
#pragma GCC diagnostic warning "-Wstrict-overflow=2"
3347-
#endif /* GCC_STRICT_OVERFLOW */
33483303
int
33493304
png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
33503305
png_int_32 divisor)
@@ -3459,9 +3414,6 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
34593414

34603415
return 0;
34613416
}
3462-
#if GCC_STRICT_OVERFLOW
3463-
#pragma GCC diagnostic pop
3464-
#endif /* GCC_STRICT_OVERFLOW */
34653417
#endif /* READ_GAMMA || INCH_CONVERSIONS */
34663418

34673419
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)

0 commit comments

Comments
 (0)