Skip to content

integer overflow in spl #19692

@chongwick

Description

@chongwick

Description

The following code:

<?php
$v_19798 = 0;
$v_19822 = curl_init();
$v_19835 = curl_exec($v_19822,);
$v_19802 = 2;
$v_19804 = 3;
$v_19806 = 4;
$v_19808 = 5;
$v_19796 = array('zero' => $v_19798,'one' => $v_19835,'two' => $v_19802,'three' => $v_19804,'four' => $v_19806,'five' => $v_19808,);
try{
$v_19796 = array('zero' => $v_19798,'one' => $v_19835,'two' => $v_19802,'three' => $v_19804,'four' => $v_19806,'five' => $v_19808,);
$v_19811 = new ArrayIterator($v_19796,);
$v_19823 = ob_start();
$v_19813 = PHP_INT_MAX;
$v_19814 = new LimitIterator($v_19811,$v_19823,$v_19813,);
foreach ($v_19814 as $v){
$v_19816 = $v;
}
$v_19815 = $v;
}
catch (OutOfBoundsException $e){
$v_19809 = $e->getMessage();
$v_19810 = '\n';
}

Resulted in this output:

/nightly_php/php-src/ext/spl/spl_iterators.c:2121:83: runtime error: signed integer overflow: 1 + 9223372036854775807 cannot be represented in type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /nightly_php/php-src/ext/spl/spl_iterators.c:2121:83

But I expected this output instead:

PHP Version

nightly

Operating System

20.04

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