Bug #75139 [Asn->Ana]: php-7.1.9/ext/gd/libgd/gd_interpolation.c:1786: suspicious if ?

From: Date: Fri, 01 Sep 2017 21:47:24 +0000
Subject: Bug #75139 [Asn->Ana]: php-7.1.9/ext/gd/libgd/gd_interpolation.c:1786: suspicious if ?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210911@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75139&edit=1 ID: 75139 Updated by: cmb@php.net Reported by: dcb314 at hotmail dot com Summary: php-7.1.9/ext/gd/libgd/gd_interpolation.c:1786: suspicious if ? -Status: Assigned +Status: Analyzed Type: Bug Package: GD related Operating System: linux PHP Version: 7.1.9RC1 Assigned To: cmb Block user comment: N Private report: N New Comment: This very issue has been fixed in external libgd with <https://github.com/libgd/libgd/commit/dd48286>. However, it seems to me that a division by zero cannot occur, because f_slop_y can only be zero if _angle is 0 or π, but in the former case f_slop_x would be 1, and the latter case cannot happen due to the switch in gdImageRotateInterpolated(). Anyhow, the respective code has been removed with <https://github.com/libgd/libgd/commit/2b26be8> to improve the quality of the rotation result. Neither of these, nor other, patches regarding gd_interpolation.c has made it to our bundled libgd yet, unfortunately. I am uncertain whether 2b26be8 could be backported without some other patches, so I think it is best to fix the typo for PHP 7.0+, and to try to sync the whole file for PHP 7.3+. > BTW, using nested ternary operators is asking for trouble. > Suggest recode in a simpler way. As the code is likely to vanish, putting the inner ternary operation in parentheses appears to be sufficient. Previous Comments: ------------------------------------------------------------------------ [2017-08-31 22:10:05] cmb@php.net It seems to me that is actually a bug, because f_slop_x > 0 && f_slop_x > 0 appears to be supposed to be f_slop_x > 0 && f_slop_y > 0 to avoid a subsequent division by zero. Thanks for reporting this issue! A test exhibiting the current misbehavior would be welcome. ------------------------------------------------------------------------ [2017-08-31 07:20:55] dcb314 at hotmail dot com Description: ------------ [php-7.1.9/ext/gd/libgd/gd_interpolation.c:1786]: (style) Same expression on both sides of '&&'. Source code is const gdFixed f_slop = f_slop_x > 0 && f_slop_x > 0 ? f_slop_x > f_slop_y ? gd_divfx(f_slop_y, f_slop_x) : gd_divfx(f_slop_x, f_slop_y) : 0; BTW, using nested ternary operators is asking for trouble. Suggest recode in a simpler way. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75139&edit=1

« previous php.bugs (#210911) next »