[php-src] Issue #20551: integer overflow in imagegammacorrect
| From: | chongwick | Date: | Fri, 21 Nov 2025 18:26:58 +0000 |
| Subject: | [php-src] Issue #20551: integer overflow in imagegammacorrect | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251271@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/20551
Author: chongwick
### Description
The following code:
```php
<?php
$v_6192 = 50;
$v_6193 = 50;
$v_6194 = imagecreatetruecolor($v_6192,$v_6193,);
$v_6195 = 0;
$v_6196 = 0;
$v_6197 = 0;
$v_6198 = 127;
$v_6199 = imagecolorallocatealpha($v_6194,$v_6195,$v_6196,$v_6197,$v_6198,);
$v_6200 = 255;
$v_2700 = 0;
$v_6202 = 0;
$v_6203 = imagecolorallocate($v_6194,$v_6200,$v_2700,$v_6202,);
$v_6204 = 0;
$v_2683 = 10;
$v_6206 = imagefill($v_6194,$v_6204,$v_2683,$v_6199,);
$v_6207 = 2;
$v_6208 = $v_6192 / $v_6207;
$v_6209 = 0;
$v_6210 = 2;
$v_6211 = $v_6192 / $v_6210;
$v_6212 = 1;
$v_6213 = $v_6193 - $v_6212;
$v_6214 = imageline($v_6194,$v_6208,$v_6209,$v_6211,$v_6213,$v_6203,);
$v_6215 = 0;
$v_6216 = 2;
$v_6217 = $v_6193 / $v_6216;
$v_6218 = 1;
$v_6219 = $v_6192 - $v_6218;
$v_6220 = 2;
$v_6221 = $v_6193 / $v_6220;
$v_6222 = imageline($v_6194,$v_6215,$v_6217,$v_6219,$v_6221,$v_6203,);
$v_2766 = INF;
$v_2767 = -($v_2766);
$v_2768 = INF;
$v_2769 = -($v_2768);
$v_2770 = fdiv($v_2767,$v_2769,);
$v_6224 = 1;
$v_6225 = imagegammacorrect($v_6194,$v_2770,$v_6224,);
```
Resulted in this output:
```
/home/w023dtc/nightly_php/php-src/ext/gd/gd.c:2470:6: runtime error: -nan is outside the range of
representable values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/home/w023dtc/nightly_php/php-src/ext/gd/gd.c:2470:6
```
### PHP Version
```plain
nightly
```
### Operating System
ubuntu 22.04