com php-src: Fixed bug #70853 (SplFixedArray throws exception when using ref variable as index): ext/spl/spl_engine.c ext/spl/test s/bug70853.phpt

From: Date: Sun, 08 Nov 2015 02:25:49 +0000
Subject: com php-src: Fixed bug #70853 (SplFixedArray throws exception when using ref variable as index): ext/spl/spl_engine.c ext/spl/test s/bug70853.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89696@lists.php.net to get a copy of this message
Commit: b48738f00b115eda59163016c24a417bef1eeda9 Author: Xinchen Hui <laruence@gmail.com> Wed, 4 Nov 2015 06:44:29 -0800 Committer: Anatol Belski <ab@php.net> Sun, 8 Nov 2015 03:25:49 +0100 Parents: aa5c9f932abd1c965ec52a23464aeadabb7e6f47 Branches: PHP-7.0.0 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b48738f00b115eda59163016c24a417bef1eeda9 Log: Fixed bug #70853 (SplFixedArray throws exception when using ref variable as index) Bugs: https://bugs.php.net/70853 Changed paths: M ext/spl/spl_engine.c A ext/spl/tests/bug70853.phpt Diff: diff --git a/ext/spl/spl_engine.c b/ext/spl/spl_engine.c index c9960d6..b3d1a3e 100644 --- a/ext/spl/spl_engine.c +++ b/ext/spl/spl_engine.c @@ -42,6 +42,7 @@ PHPAPI zend_long spl_offset_convert_to_long(zval *offset) /* {{{ */ { zend_ulong idx; +try_again: switch (Z_TYPE_P(offset)) { case IS_STRING: if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), idx)) { @@ -56,6 +57,9 @@ PHPAPI zend_long spl_offset_convert_to_long(zval *offset) /* {{{ */ return 0; case IS_TRUE: return 1; + case IS_REFERENCE: + offset = Z_REFVAL_P(offset); + goto try_again; case IS_RESOURCE: return Z_RES_HANDLE_P(offset); } diff --git a/ext/spl/tests/bug70853.phpt b/ext/spl/tests/bug70853.phpt new file mode 100644 index 0000000..99530ec --- /dev/null +++ b/ext/spl/tests/bug70853.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #70853 (SplFixedArray throws exception when using ref variable as index) +--FILE-- +<?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'; + +?> +--EXPECT-- +ok

« previous php.cvs (#89696) next »