]> granicus.if.org Git - php/commitdiff
Fixed bug #27268 (Bad references accentuated by clone).
authorDmitry Stogov <dmitry@php.net>
Thu, 23 Jun 2005 08:21:03 +0000 (08:21 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 23 Jun 2005 08:21:03 +0000 (08:21 +0000)
NEWS
Zend/tests/bug27268.phpt [new file with mode: 0755]
Zend/zend_execute.c

diff --git a/NEWS b/NEWS
index 73891459ef392b8e9141bbe83df8180b4b8075e0..de255a8785c6e7244020689e57cb5a1aafb5a342 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2005, PHP 5.1 Beta 3
+- Fixed bug #27268 (Bad references accentuated by clone). (Dmitry)
 
 22 Jun 2005, PHP 5.1 Beta 2
 - Improved PHP extension loading mechanism with support for module dependencies
diff --git a/Zend/tests/bug27268.phpt b/Zend/tests/bug27268.phpt
new file mode 100755 (executable)
index 0000000..a86e8d0
--- /dev/null
@@ -0,0 +1,28 @@
+--TEST--
+Bug #27268 (Bad references accentuated by clone)
+--FILE--
+<?php
+class A
+{
+    public function &getA()
+    {
+        return $this->a;
+    }
+}
+
+$A = new A;
+$A->a = array(1);
+$x = $A->getA();
+$clone = clone $A;
+$clone->a = array();
+print_r($A);
+?>
+--EXPECT--
+A Object
+(
+    [a] => Array
+        (
+            [0] => 1
+        )
+
+)
index 0aeee7f5bcb81c0514315aba66b5e7fee68b7513..3a549261010f3cb79f002058df53c8cf41c1fb8a 100644 (file)
@@ -70,6 +70,9 @@ static inline void zend_pzval_unlock_func(zval *z, zend_free_op *should_free)
 /*             should_free->is_var = 1; */
        } else {
                should_free->var = 0;
+               if (z->is_ref && z->refcount == 1) {
+                       z->is_ref = 0;
+               }
        }
 }