com php-src: Fixed bug #71067 (Local object in class method stays in memory for each call): NEWS Zend/tests/bug71067.phpt Zend/zend_execu te.c

From: Date: Wed, 09 Dec 2015 13:07:59 +0000
Subject: com php-src: Fixed bug #71067 (Local object in class method stays in memory for each call): NEWS Zend/tests/bug71067.phpt Zend/zend_execu te.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-90184@lists.php.net to get a copy of this message
Commit: 4c379392b2873cf2d5407cade3f747401f7df96c Author: Xinchen Hui <laruence@gmail.com> Wed, 9 Dec 2015 21:07:59 +0800 Parents: f248309b7485fea08e3c112adab97bfa1fc74df4 Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4c379392b2873cf2d5407cade3f747401f7df96c Log: Fixed bug #71067 (Local object in class method stays in memory for each call) Bugs: https://bugs.php.net/71067 Changed paths: M NEWS A Zend/tests/bug71067.phpt M Zend/zend_execute.c Diff: diff --git a/NEWS b/NEWS index 33bd38c..8766bbb 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? Jan 2016 PHP 7.0.2 +- Core: + . Fixed bug #71067 (Local object in class method stays in memory for each + call). (Laruence) + - Mbstring: . Fixed bug #71066 (mb_send_mail: Program terminated with signal SIGSEGV, Segmentation fault). (Laruence) diff --git a/Zend/tests/bug71067.phpt b/Zend/tests/bug71067.phpt new file mode 100644 index 0000000..b2a1b31 --- /dev/null +++ b/Zend/tests/bug71067.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #71067 (Local object in class method stays in memory for each call) +--INI-- +opcache.enable=0 +error_reporting=0 +--FILE-- +<?php +class Test { + public function test(){ + $arr = (object) [ + 'children' => [] + ]; + $arr->children[] = 1; + return $arr; + } +} + +$o = new Test(); +$o->test(); + +print_r($o->test()); +?> +--EXPECT-- +stdClass Object +( + [children] => Array + ( + [0] => 1 + ) + +) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index f851833..2ca3114 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1954,6 +1954,12 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c return; } } else if (EXPECTED(zobj->properties != NULL)) { + if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { + if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { + GC_REFCOUNT(zobj->properties)--; + } + zobj->properties = zend_array_dup(zobj->properties); + } retval = zend_hash_find(zobj->properties, Z_STR_P(prop_ptr)); if (EXPECTED(retval)) { ZVAL_INDIRECT(result, retval);

« previous php.cvs (#90184) next »