[php-src] Issue #20622: integer overflow in ImageString

[email protected] (chongwick)
Newsgroups php.bugs
Message-ID <TzKxhrjcbqamPxf9iPlxYDnNwYybLKmUDqv2RkPiRVI@main.internal.php.net>
Issue: https://github.com/php/php-src/issues/20622
Author: chongwick

### Description

The following code:

```php
<?php
$im = imagecreate(100, 30);

$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

imagestring($im, 5, 2147483647, 0, 'Hello world!', $textcolor);
```

Resulted in this output:
```
/home/w023dtc/nightly_php/php-src/ext/gd/gd.c:3020:7: runtime error: signed integer overflow: 2147483647 + 9 cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/w023dtc/nightly_php/php-src/ext/gd/gd.c:3020:7
```



### PHP Version

```plain
nightly
```

### Operating System

ubuntu 22.04
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.