Bug #70853 [Opn->Csd]: SplFixedArray throws exception when using ref variable as index
| From: | laruence@php.net | Date: | Wed, 04 Nov 2015 14:45:01 +0000 |
| Subject: | Bug #70853 [Opn->Csd]: SplFixedArray throws exception when using ref variable as index | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-197018@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70853&edit=1
ID: 70853
Updated by: laruence@php.net
Reported by: php at maisqi dot com
Summary: SplFixedArray throws exception when using ref
variable as index
-Status: Open
+Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Windows 8 x64
PHP Version: 7.0.0RC6
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e4ac4e75b5dbc39ed52ff998cb4f2053541ed2d8
Log: Fixed bug #70853 (SplFixedArray throws exception when using ref variable as index)
Previous Comments:
------------------------------------------------------------------------
[2015-11-04 13:01:01] php at maisqi dot com
Description:
------------
PHP7 throws an exception if we try accessing a member by an index stored in a referenced variable.
In other words, if we have the index in $var and, by one reason or another, make a reference to it
(like $ndx2 =& $ndx) we no longer can use it to access a SplFixedArray. (We would have to copy
$ndx, or $ndx2, to a temp normal variable and use it instead.)
Test script:
---------------
<?php
$list = new SplFixedArray(10);
$ndx = 1;
$ndx2 =& $ndx;
$list[$ndx] = 123; // This throws an exception;
$list[$ndx2] = 123; // as does this, to.
echo 'ok';
Expected result:
----------------
It should just print "ok".
Actual result:
--------------
"Uncaught RuntimeException: Index invalid or out of range"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70853&edit=1