From fd463f6be735347a4a807e1969732366a153599a Mon Sep 17 00:00:00 2001 From: irwir Date: Fri, 19 Jan 2024 19:35:55 +0300 Subject: [PATCH] Skip reassigning of the initialization value --- pngrutil.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pngrutil.c b/pngrutil.c index d31dc21dae..99ab84f7fb 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -3164,17 +3164,15 @@ png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length) # endif if (png_ptr->chunk_name == png_IDAT) { - png_alloc_size_t idat_limit = PNG_UINT_31_MAX; size_t row_factor = (size_t)png_ptr->width * (size_t)png_ptr->channels * (png_ptr->bit_depth > 8? 2: 1) + 1 + (png_ptr->interlaced? 6: 0); - if (png_ptr->height > PNG_UINT_32_MAX/row_factor) - idat_limit = PNG_UINT_31_MAX; - else - idat_limit = png_ptr->height * row_factor; + png_alloc_size_t idat_limit = + (png_ptr->height > PNG_UINT_32_MAX/row_factor) ? + PNG_UINT_31_MAX : png_ptr->height * row_factor; row_factor = row_factor > 32566? 32566 : row_factor; idat_limit += 6 + 5*(idat_limit/row_factor+1); /* zlib+deflate overhead */ idat_limit=idat_limit < PNG_UINT_31_MAX? idat_limit : PNG_UINT_31_MAX;