Skip to content

Commit 1b79da9

Browse files
author
Moriyoshi Koizumi
committed
Added test case for bug #22231
1 parent 3b547e6 commit 1b79da9

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/lang/bug22231.phpt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
Bug #22231 (segfault when returning a global variable by reference)
3+
--FILE--
4+
<?php
5+
class foo {
6+
var $fubar = 'fubar';
7+
}
8+
9+
function &foo(){
10+
$GLOBALS['foo'] = &new foo();
11+
return $GLOBALS['foo'];
12+
}
13+
$bar = &foo();
14+
var_dump($bar);
15+
var_dump($bar->fubar);
16+
unset($bar);
17+
$bar = &foo();
18+
var_dump($bar->fubar);
19+
20+
$foo = &foo();
21+
var_dump($foo);
22+
var_dump($foo->fubar);
23+
unset($foo);
24+
$foo = &foo();
25+
var_dump($foo->fubar);
26+
?>
27+
--EXPECT--
28+
object(foo)(1) {
29+
["fubar"]=>
30+
string(5) "fubar"
31+
}
32+
string(5) "fubar"
33+
string(5) "fubar"
34+
object(foo)(1) {
35+
["fubar"]=>
36+
string(5) "fubar"
37+
}
38+
string(5) "fubar"
39+
string(5) "fubar"

0 commit comments

Comments
 (0)