php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71028 Undefined index with ArrayIterator
Submitted: 2015-12-04 11:54 UTC Modified: -
From: vincent dot guth at gmail dot com Assigned:
Status: Closed Package: Output Control
PHP Version: 7.0.0 OS:
Private report: No CVE-ID: None
 [2015-12-04 11:54 UTC] vincent dot guth at gmail dot com
Description:
------------
Hello

I have a PHP warning with ArrayIterator when used with references.
Thank you for looking at this.


My test scripts works as expected if you replace 'cast($b)' by '$b = (int)$b'

Test script:
---------------
<?php
function cast(&$a) {
	$a = (int)$a;
}

$a = new ArrayIterator;
$a[-1] = 123;

$b = "-1";
cast($b);

echo $a[$b];
?>

Expected result:
----------------
123

Actual result:
--------------
PHP Warning:  Illegal offset type in /tmp/test.php on line 12



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-04 14:45 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7ac24aa661b9bc9983bb92a734e2c9993db147c5
Log: Fixed bug #71028 (Undefined index with ArrayIterator)
 [2015-12-04 14:45 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2016-07-20 11:35 UTC] davey@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7ac24aa661b9bc9983bb92a734e2c9993db147c5
Log: Fixed bug #71028 (Undefined index with ArrayIterator)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC