Skip to content

Signed integer overflow in array_reduce #17197

@YuanchengJiang

Description

@YuanchengJiang

Description

The following code:

<?php
$input = [new DoOperationNoCast(25), new DoOperationNoCast(PHP_INT_MIN), new DoOperationNoCast(10)];
array_reduce($input, fn($carry, $value) => $carry * $value, 1);

Resulted in this output:

/home/phpfuzz/WorkSpace/flowfusion/php-src/ext/zend_test/object_handlers.c:78:28: runtime error: signed integer overflow: 25 * -9223372036854775808 cannot be represented in type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/phpfuzz/WorkSpace/flowfusion/php-src/ext/zend_test/object_handlers.c:78:28 in

PHP Version

nightly

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions