diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2026-01-20 18:01:12 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2026-01-20 18:01:12 +0100 |
| commit | 2f7d7adfcf4bec55fa5e007947e4a455e85d8930 (patch) | |
| tree | 2258a700e13d8582fcf5eedb30394c78641d739a /png/png.c | |
| parent | d30ca1866463c4091c3e0bcf5ca730f409ddc78d (diff) | |
Update bundled libpng to last upstream version 1.6.54
Diffstat (limited to 'png/png.c')
| -rw-r--r-- | png/png.c | 37 |
1 files changed, 21 insertions, 16 deletions
@@ -1,6 +1,6 @@ /* png.c - location for general purpose libpng functions * - * Copyright (c) 2018-2025 Cosmin Truta + * Copyright (c) 2018-2026 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -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_50 Your_png_h_is_not_version_1_6_50; +typedef png_libpng_version_1_6_54 Your_png_h_is_not_version_1_6_54; /* Sanity check the chunks definitions - PNG_KNOWN_CHUNKS from pngpriv.h and the * corresponding macro definitions. This causes a compile time failure if @@ -101,17 +101,24 @@ png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check) #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) /* Function to allocate memory for zlib */ PNG_FUNCTION(voidpf /* PRIVATE */, -png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED) +png_zalloc,(voidpf png_ptr, uInt items, uInt size), + PNG_ALLOCATED) { png_alloc_size_t num_bytes = size; if (png_ptr == NULL) return NULL; - if (items >= (~(png_alloc_size_t)0)/size) + /* This check against overflow is vestigial, dating back from + * the old times when png_zalloc used to be an exported function. + * We're still keeping it here for now, as an extra-cautious + * prevention against programming errors inside zlib, although it + * should rather be a debug-time assertion instead. + */ + if (size != 0 && items >= (~(png_alloc_size_t)0) / size) { - png_warning (png_voidcast(png_structrp, png_ptr), - "Potential overflow in png_zalloc()"); + png_warning(png_voidcast(png_structrp, png_ptr), + "Potential overflow in png_zalloc()"); return NULL; } @@ -238,10 +245,6 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver) png_warning(png_ptr, m); #endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags = 0; -#endif - return 0; } @@ -255,7 +258,8 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver) PNG_FUNCTION(png_structp /* PRIVATE */, png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) + png_malloc_ptr malloc_fn, png_free_ptr free_fn), + PNG_ALLOCATED) { png_struct create_struct; # ifdef PNG_SETJMP_SUPPORTED @@ -359,7 +363,8 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, /* Allocate the memory for an info_struct for the application. */ PNG_FUNCTION(png_infop,PNGAPI -png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED) +png_create_info_struct,(png_const_structrp png_ptr), + PNG_ALLOCATED) { png_inforp info_ptr; @@ -815,8 +820,8 @@ png_get_copyright(png_const_structrp png_ptr) return PNG_STRING_COPYRIGHT #else return PNG_STRING_NEWLINE \ - "libpng version 1.6.50" PNG_STRING_NEWLINE \ - "Copyright (c) 2018-2025 Cosmin Truta" PNG_STRING_NEWLINE \ + "libpng version 1.6.54" 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 \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ @@ -2255,8 +2260,8 @@ PNG_FP_End: int png_check_fp_string(png_const_charp string, size_t size) { - int state=0; - size_t char_index=0; + int state = 0; + size_t char_index = 0; if (png_check_fp_number(string, size, &state, &char_index) != 0 && (char_index == size || string[char_index] == 0)) |
