From 8c7ed2e3b2f002eaa3cea40802c694e923ecfa58 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 30 Jan 2025 23:07:55 +0200 Subject: [PATCH] fix: Typo in a preprocessor directive This is a regression of commit 2519a03418af2108d3bd8c269ba01ab72ae240ef "refactor: Clean up the checking of chunk lengths and allocation limits" Compilation would break under the "right" non-default configuration. (Oopsie!) Also clean up comments in the surrounding code. Reported-by: chris0e3 Signed-off-by: Cosmin Truta --- png.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/png.c b/png.c index 830b642d4..f261753bc 100644 --- a/png.c +++ b/png.c @@ -268,27 +268,22 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, */ memset(&create_struct, 0, (sizeof create_struct)); - /* Added at libpng-1.2.6 */ # ifdef PNG_USER_LIMITS_SUPPORTED create_struct.user_width_max = PNG_USER_WIDTH_MAX; create_struct.user_height_max = PNG_USER_HEIGHT_MAX; # ifdef PNG_USER_CHUNK_CACHE_MAX - /* Added at libpng-1.2.43 and 1.4.0 */ create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX; # endif - /* Added at libpng-1.2.43 and 1.4.1, required only for read but exists - * in png_struct regardless. - */ # if PNG_USER_CHUNK_MALLOC_MAX > 0 /* default to compile-time limit */ create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX; - /* No compile time limit so initialize to the system limit: */ -# elif (defined PNG_MAX_MALLOC_64K/* legacy system limit */ + /* No compile-time limit, so initialize to the system limit: */ +# elif defined PNG_MAX_MALLOC_64K /* legacy system limit */ create_struct.user_chunk_malloc_max = 65536U; -# else /* modern system limit SIZE_MAX (C99) */ +# else /* modern system limit SIZE_MAX (C99) */ create_struct.user_chunk_malloc_max = PNG_SIZE_MAX; # endif # endif