Browse Source
Fixed bug #52614 (Memory leak when writing on uninitialized variable returned from method call)
experimental/with_scalar_types
Fixed bug #52614 (Memory leak when writing on uninitialized variable returned from method call)
experimental/with_scalar_types
7 changed files with 199 additions and 13 deletions
-
2NEWS
-
83Zend/tests/bug52614.phpt
-
53Zend/zend_compile.c
-
6Zend/zend_language_parser.y
-
21Zend/zend_vm_def.h
-
46Zend/zend_vm_execute.h
-
1Zend/zend_vm_opcodes.h
@ -0,0 +1,83 @@ |
|||
--TEST-- |
|||
Bug #52614 (Memory leak when writing on uninitialized variable returned from method call) |
|||
--FILE-- |
|||
<?php |
|||
class foo { |
|||
public $a1; |
|||
public $a2 = array(); |
|||
public $a3; |
|||
public $o1; |
|||
public $o2; |
|||
|
|||
public function f1() { |
|||
return $this->a1; |
|||
} |
|||
|
|||
public function f2() { |
|||
return $this->a2; |
|||
} |
|||
|
|||
public function f3() { |
|||
$this->a3 = array(); |
|||
return $this->a3; |
|||
} |
|||
|
|||
public function f4() { |
|||
return $this->o1; |
|||
} |
|||
|
|||
public function f5() { |
|||
$this->o2 = new stdClass; |
|||
return $this->o2; |
|||
} |
|||
|
|||
public function &f6() { |
|||
return $this->a1; |
|||
} |
|||
|
|||
public function f7(&$x) { |
|||
$x = 2; |
|||
} |
|||
|
|||
} |
|||
|
|||
$foo = new foo; |
|||
|
|||
$foo->f1()[0] = 1; |
|||
var_dump($foo->a1); |
|||
|
|||
$foo->f2()[0] = 1; |
|||
var_dump($foo->a2); |
|||
|
|||
$foo->f3()[0] = 1; |
|||
var_dump($foo->a3); |
|||
|
|||
$foo->f4()->a = 1; |
|||
var_dump($foo->o1); |
|||
|
|||
$foo->f5()->a = 1; |
|||
var_dump($foo->o2); |
|||
|
|||
$foo->a1[0] = 1; |
|||
$foo->f7($foo->f6()[0]); |
|||
var_dump($foo->a1[0]); |
|||
$foo->f1()[0]++; |
|||
var_dump($foo->a1[0]); |
|||
$foo->f6()[0]++; |
|||
var_dump($foo->a1[0]); |
|||
--EXPECTF-- |
|||
NULL |
|||
array(0) { |
|||
} |
|||
array(0) { |
|||
} |
|||
|
|||
Strict Standards: Creating default object from empty value in %sbug52614.php on line 52 |
|||
NULL |
|||
object(stdClass)#%d (1) { |
|||
["a"]=> |
|||
int(1) |
|||
} |
|||
int(2) |
|||
int(2) |
|||
int(3) |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue