Skip to content

Commit a628a6a

Browse files
author
Moriyoshi Koizumi
committed
Added test case for bug #22367
1 parent 93b6d05 commit a628a6a

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

tests/lang/bug22367.phpt

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
--TEST--
2+
Bug #22367 (weird zval allocation problem)
3+
--FILE--
4+
<?php
5+
class foo
6+
{
7+
var $test = array(0, 1, 2, 3, 4);
8+
9+
function a($arg) {
10+
var_dump(array_key_exists($arg, $this->test));
11+
return $this->test[$arg];
12+
}
13+
14+
function b() {
15+
@$this->c();
16+
17+
$zero = $this->test[0];
18+
$one = $this->test[1];
19+
$two = $this->test[2];
20+
$three = $this->test[3];
21+
$four = $this->test[4];
22+
return array($zero, $one, $two, $three, $four);
23+
}
24+
25+
function c() {
26+
return $this->a($this->d());
27+
}
28+
29+
function d() {}
30+
}
31+
32+
class bar extends foo
33+
{
34+
var $i = 0;
35+
var $idx;
36+
37+
function bar($idx) {
38+
$this->idx = $idx;
39+
}
40+
41+
function &a($arg){
42+
return parent::a($arg);
43+
}
44+
function d(){
45+
return $this->idx;
46+
}
47+
}
48+
49+
$a = new bar(5);
50+
var_dump($a->idx);
51+
@$a->c();
52+
$b = $a->b();
53+
var_dump($b);
54+
var_dump($a->test);
55+
56+
$a = new bar(2);
57+
var_dump($a->idx);
58+
@$a->c();
59+
$b = $a->b();
60+
var_dump($b);
61+
var_dump($a->test);
62+
63+
?>
64+
--EXPECT--
65+
int(5)
66+
bool(false)
67+
bool(false)
68+
array(5) {
69+
[0]=>
70+
int(0)
71+
[1]=>
72+
int(1)
73+
[2]=>
74+
int(2)
75+
[3]=>
76+
int(3)
77+
[4]=>
78+
int(4)
79+
}
80+
array(5) {
81+
[0]=>
82+
int(0)
83+
[1]=>
84+
int(1)
85+
[2]=>
86+
int(2)
87+
[3]=>
88+
int(3)
89+
[4]=>
90+
int(4)
91+
}
92+
int(2)
93+
bool(true)
94+
bool(true)
95+
array(5) {
96+
[0]=>
97+
int(0)
98+
[1]=>
99+
int(1)
100+
[2]=>
101+
int(2)
102+
[3]=>
103+
int(3)
104+
[4]=>
105+
int(4)
106+
}
107+
array(5) {
108+
[0]=>
109+
int(0)
110+
[1]=>
111+
int(1)
112+
[2]=>
113+
int(2)
114+
[3]=>
115+
int(3)
116+
[4]=>
117+
int(4)
118+
}

0 commit comments

Comments
 (0)