]> granicus.if.org Git - php/commitdiff
Added test case for bug #22231
authorMoriyoshi Koizumi <moriyoshi@php.net>
Sat, 15 Feb 2003 15:15:14 +0000 (15:15 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Sat, 15 Feb 2003 15:15:14 +0000 (15:15 +0000)
tests/lang/bug22231.phpt [new file with mode: 0644]

diff --git a/tests/lang/bug22231.phpt b/tests/lang/bug22231.phpt
new file mode 100644 (file)
index 0000000..0d4d19d
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+Bug #22231 (segfault when returning a global variable by reference)
+--FILE--
+<?php
+class foo {
+    var $fubar = 'fubar';
+}
+
+function &foo(){
+    $GLOBALS['foo'] = &new foo();
+    return $GLOBALS['foo'];
+}
+$bar = &foo();
+var_dump($bar);
+var_dump($bar->fubar);
+unset($bar);
+$bar = &foo();
+var_dump($bar->fubar);
+
+$foo = &foo();
+var_dump($foo);
+var_dump($foo->fubar);
+unset($foo);
+$foo = &foo();
+var_dump($foo->fubar);
+?>
+--EXPECT--
+object(foo)(1) {
+  ["fubar"]=>
+  string(5) "fubar"
+}
+string(5) "fubar"
+string(5) "fubar"
+object(foo)(1) {
+  ["fubar"]=>
+  string(5) "fubar"
+}
+string(5) "fubar"
+string(5) "fubar"