File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / bug52614.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:34:36 2012 UTC (12 years, 10 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, HEAD
php 5.4.3+patches

    1: --TEST--
    2: Bug #52614 (Memory leak when writing on uninitialized variable returned from method call)
    3: --FILE--
    4: <?php
    5: class foo {
    6: 	public $a1;
    7: 	public $a2 = array();
    8: 	public $a3;
    9: 	public $o1;
   10: 	public $o2;
   11: 	
   12: 	public function f1() {
   13: 		return $this->a1;
   14: 	}
   15: 
   16: 	public function f2() {
   17: 		return $this->a2;
   18: 	}
   19: 
   20: 	public function f3() {
   21: 		$this->a3 = array();
   22: 		return $this->a3;
   23: 	}
   24: 
   25: 	public function f4() {
   26: 		return $this->o1;
   27: 	}
   28: 
   29: 	public function f5() {
   30: 		$this->o2 = new stdClass;
   31: 		return $this->o2;
   32: 	}
   33: 
   34: 	public function &f6() {
   35: 		return $this->a1;
   36: 	}
   37: 
   38: 	public function f7(&$x) {
   39: 		$x = 2;
   40: 	}
   41: 
   42: }
   43: 
   44: $foo = new foo;
   45: 
   46: $foo->f1()[0] = 1;
   47: var_dump($foo->a1);
   48: 
   49: $foo->f2()[0] = 1;
   50: var_dump($foo->a2);
   51: 
   52: $foo->f3()[0] = 1;
   53: var_dump($foo->a3);
   54: 
   55: $foo->f4()->a = 1;
   56: var_dump($foo->o1);
   57: 
   58: $foo->f5()->a = 1;
   59: var_dump($foo->o2);
   60: 
   61: $foo->a1[0] = 1;
   62: $foo->f7($foo->f6()[0]);
   63: var_dump($foo->a1[0]);
   64: $foo->f1()[0]++;
   65: var_dump($foo->a1[0]);
   66: $foo->f6()[0]++;
   67: var_dump($foo->a1[0]);
   68: --EXPECTF--
   69: NULL
   70: array(0) {
   71: }
   72: array(0) {
   73: }
   74: 
   75: Warning: Creating default object from empty value in %sbug52614.php on line 52
   76: NULL
   77: object(stdClass)#%d (1) {
   78:   ["a"]=>
   79:   int(1)
   80: }
   81: int(2)
   82: int(2)
   83: int(3)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>