Bug #72813 [Opn->Ver]: Different behavior for PHP 5.6.* and PHP 7.* when values are returned by ref.
| From: | laruence@php.net | Date: | Fri, 12 Aug 2016 07:55:23 +0000 |
| Subject: | Bug #72813 [Opn->Ver]: Different behavior for PHP 5.6.* and PHP 7.* when values are returned by ref. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203202@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72813&edit=1
ID: 72813
Updated by: laruence@php.net
Reported by: smilimko at gmail dot com
Summary: Different behavior for PHP 5.6.* and PHP 7.* when
values are returned by ref.
-Status: Open
+Status: Verified
Type: Bug
Package: Class/Object related
Operating System: Windows 10
PHP Version: 7.0.9
-Assigned To:
+Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
actually, this leads to a uaf problem....
Previous Comments:
------------------------------------------------------------------------
[2016-08-11 13:10:54] smilimko at gmail dot com
Description:
------------
I use PHP 7.0.4
When I run the script represented below I get the different result for versions 5.6.* and 7.0. If it
is not a bug I would want to know what changes were made in PHP that may cause that different
behavior.
Test script:
---------------
class Test
{
private $props = ['a' => 'text', 'b' => 1];
public function &__get($prop)
{
return $this->props[$prop];
}
public function __set($prop, $value)
{
if ($prop === 'b') $value = [$value];
$this->props[$prop] = $value;
}
public function getProperties()
{
return [$this->props];
}
}
$obj = new Test;
$obj->b = $obj->b;
print_r($obj->getProperties());
Expected result:
----------------
Array
(
[0] => Array
(
[a] => text
[b] => Array
(
[0] => 1
)
)
)
Actual result:
--------------
Array
(
[0] => Array
(
[a] => text
[b] => Array
*RECURSION*
)
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72813&edit=1