Skip to content

integer overflow in imagescale #20602

Closed
Closed

Description

@chongwick

Description

The following code:

<?php
$v_17401 = 2;
$v_3914 = 1;
$v_3915 = imagecreatetruecolor($v_17401,$v_3914,);
$v_3917 = 1;
$v_3918 = -($v_3917);
$v_17364 = 9223372036854775807;
$v_17415 = 1;
$v_3922 = imagescale($v_3915,$v_3918,$v_17364,$v_17415,);

Resulted in this output:

/home/w023dtc/nightly_php/php-src/ext/gd/gd.c:3937:18: runtime error: signed integer overflow: 9223372036854775807 * 2 cannot be represented in type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/w023dtc/nightly_php/php-src/ext/gd/gd.c:3937:18

But I expected this output instead:

PHP Version

nightly

Operating System

No response

Activity

  1. self-assigned this
    on Nov 28, 2025
  2. added a commit that references this issue on Nov 28, 2025
    8e481aa
  3. added 4 commits that reference this issue on Nov 29, 2025
    6d54908
    848269d
    dddd050
    c8e13af
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