Skip to content

integer overflow in ImageString #20622

Closed
Closed

Description

@chongwick

Description

The following code:

<?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

nightly

Operating System

ubuntu 22.04

Activity

  1. self-assigned this
    on Nov 29, 2025
  2. devnexen commented on Nov 29, 2025

    @devnexen
    Member

    imagestringup has a similar issue.

  3. added 2 commits that reference this issue on Dec 4, 2025
    d49fe3e
    9f654de
  4. added 3 commits that reference this issue on Dec 4, 2025
    2c2852a
    400aa84
    8504b18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions