From b704036531972c9367690970dc3de6df53e8bb97 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Sat, 11 Jun 2011 14:20:22 -0500 Subject: [PATCH] [devel] Allow png_set_user_limits() to increase limits as well as reduce them. --- CHANGES | 6 ++++-- png.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index c7c0a2c0c..f42bac020 100644 --- a/CHANGES +++ b/CHANGES @@ -3419,9 +3419,11 @@ Version 1.5.3rc02 [June 8, 2011] Version 1.5.3beta11 [June 11, 2011] Fixed png_handle_sCAL which is broken in 1.5; added sCAL to pngtest.png - Revised documentation about png_set_user_limits() to say that it can - only be used to reduce the defined limit, and that it also affects + Revised documentation about png_set_user_limits() to say that it also affects png writing. + Revised handling of png_set_user_limits() so that it can increase the + limit beyond the PNG_USER_WIDTH|HEIGHT_MAX; previously it could only + reduce it. Make the 16-to-8 scaling accurate. Dividing by 256 with no rounding is wrong (high by one) 25% of the time. Dividing by 257 with rounding is wrong in 128 out of 65536 cases. Getting the right answer all the time diff --git a/png.c b/png.c index bf31bddd2..83cd96f69 100644 --- a/png.c +++ b/png.c @@ -820,7 +820,7 @@ png_check_IHDR(png_structp png_ptr, } # ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (width > png_ptr->user_width_max || width > PNG_USER_WIDTH_MAX) + if (width > png_ptr->user_width_max) # else if (width > PNG_USER_WIDTH_MAX) @@ -831,7 +831,7 @@ png_check_IHDR(png_structp png_ptr, } # ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (height > png_ptr->user_height_max || height > PNG_USER_HEIGHT_MAX) + if (height > png_ptr->user_height_max) # else if (height > PNG_USER_HEIGHT_MAX) # endif