|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75139 php-7.1.9/ext/gd/libgd/gd_interpolation.c:1786: suspicious if ?
Submitted: 2017-08-31 07:20 UTC Modified: 2017-09-01 21:47 UTC
From: dcb314 at hotmail dot com Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: 7.1.9RC1 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: dcb314 at hotmail dot com
New email:
PHP Version: OS:


 [2017-08-31 07:20 UTC] dcb314 at hotmail dot com
[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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-08-31 14:00 UTC]
-Assigned To: +Assigned To: cmb
 [2017-08-31 22:10 UTC]
-Package: Compile Warning +Package: GD related
 [2017-08-31 22:10 UTC]
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

Thanks for reporting this issue!

A test exhibiting the current misbehavior would be welcome.
 [2017-09-01 21:47 UTC]
-Status: Assigned +Status: Analyzed
 [2017-09-01 21:47 UTC]
This very issue has been fixed in external libgd with
<>. 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
<> 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.
 [2017-09-01 22:29 UTC]
Automatic comment on behalf of
Log: Fixed bug #75139 (libgd/gd_interpolation.c:1786: suspicious if ?)
 [2017-09-01 22:29 UTC]
-Status: Analyzed +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 16:01:28 2024 UTC