xref: /PHP-7.1/Zend/tests/bug52041.phpt (revision 70668fd8)
1--TEST--
2Bug #52041 (Memory leak when writing on uninitialized variable returned from function)
3--FILE--
4<?php
5function foo() {
6	return $x;
7}
8
9foo()->a = 1;
10foo()->a->b = 2;
11foo()->a++;
12foo()->a->b++;
13foo()->a += 2;
14foo()->a->b += 2;
15
16foo()[0] = 1;
17foo()[0][0] = 2;
18foo()[0]++;
19foo()[0][0]++;
20foo()[0] += 2;
21foo()[0][0] += 2;
22
23var_dump(foo());
24?>
25--EXPECTF--
26Notice: Undefined variable: x in %sbug52041.php on line 3
27
28Warning: Creating default object from empty value in %sbug52041.php on line 6
29
30Notice: Undefined variable: x in %sbug52041.php on line 3
31
32Warning: Creating default object from empty value in %sbug52041.php on line 7
33
34Notice: Undefined variable: x in %sbug52041.php on line 3
35
36Warning: Creating default object from empty value in %sbug52041.php on line 8
37
38Notice: Undefined property: stdClass::$a in %sbug52041.php on line 8
39
40Notice: Undefined variable: x in %sbug52041.php on line 3
41
42Notice: Undefined property: stdClass::$a in %sbug52041.php on line 9
43
44Warning: Creating default object from empty value in %sbug52041.php on line 9
45
46Notice: Undefined property: stdClass::$b in %sbug52041.php on line 9
47
48Notice: Undefined variable: x in %sbug52041.php on line 3
49
50Warning: Creating default object from empty value in %sbug52041.php on line 10
51
52Notice: Undefined property: stdClass::$a in %sbug52041.php on line 10
53
54Notice: Undefined variable: x in %sbug52041.php on line 3
55
56Notice: Undefined property: stdClass::$a in %sbug52041.php on line 11
57
58Warning: Creating default object from empty value in %sbug52041.php on line 11
59
60Notice: Undefined property: stdClass::$b in %sbug52041.php on line 11
61
62Notice: Undefined variable: x in %sbug52041.php on line 3
63
64Notice: Undefined variable: x in %sbug52041.php on line 3
65
66Notice: Undefined variable: x in %sbug52041.php on line 3
67
68Notice: Undefined offset: 0 in %sbug52041.php on line 15
69
70Notice: Undefined variable: x in %sbug52041.php on line 3
71
72Notice: Undefined offset: 0 in %sbug52041.php on line 16
73
74Notice: Undefined offset: 0 in %sbug52041.php on line 16
75
76Notice: Undefined variable: x in %sbug52041.php on line 3
77
78Notice: Undefined offset: 0 in %sbug52041.php on line 17
79
80Notice: Undefined variable: x in %sbug52041.php on line 3
81
82Notice: Undefined offset: 0 in %sbug52041.php on line 18
83
84Notice: Undefined offset: 0 in %sbug52041.php on line 18
85
86Notice: Undefined variable: x in %sbug52041.php on line 3
87NULL
88