cvs: ZendEngine2 / zend_objects_API.c /tests bug36006.phpt
| From: | Dmitry Stogov | Date: | Mon, 16 Jan 2006 10:12:54 +0000 |
| Subject: | cvs: ZendEngine2 / zend_objects_API.c /tests bug36006.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4523@lists.php.net to get a copy of this message | ||
dmitry Mon Jan 16 10:12:54 2006 UTC
Modified files:
/ZendEngine2 zend_objects_API.c
/ZendEngine2/tests bug36006.phpt
Log:
Fixed bug #36006 (Problem with $this in __destruct())
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_objects_API.c?r1=1.52&r2=1.53&diff_format=u
Index: ZendEngine2/zend_objects_API.c
diff -u ZendEngine2/zend_objects_API.c:1.52 ZendEngine2/zend_objects_API.c:1.53
--- ZendEngine2/zend_objects_API.c:1.52 Wed Jan 4 23:52:06 2006
+++ ZendEngine2/zend_objects_API.c Mon Jan 16 10:12:54 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_objects_API.c,v 1.52 2006/01/04 23:52:06 andi Exp $ */
+/* $Id: zend_objects_API.c,v 1.53 2006/01/16 10:12:54 dmitry Exp $ */
#include "zend.h"
#include "zend_globals.h"
@@ -52,7 +52,9 @@
if (!objects->object_buckets[i].destructor_called) {
objects->object_buckets[i].destructor_called = 1;
if (obj->dtor && obj->object) {
+ obj->refcount++;
obj->dtor(obj->object, i TSRMLS_CC);
+ obj->refcount--;
}
}
}
http://cvs.php.net/viewcvs.cgi/ZendEngine2/tests/bug36006.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug36006.phpt
diff -u /dev/null ZendEngine2/tests/bug36006.phpt:1.2
--- /dev/null Mon Jan 16 10:12:54 2006
+++ ZendEngine2/tests/bug36006.phpt Mon Jan 16 10:12:54 2006
@@ -0,0 +1,30 @@
+--TEST--
+Bug #36006 (Problem with $this in __destruct())
+--FILE--
+<?php
+
+class Person {
+ public $dad;
+ public function __destruct() {
+ $this->dad = null; /* no segfault if this is commented out */
+ }
+}
+
+class Dad extends Person {
+ public $son;
+ public function __construct() {
+ $this->son = new Person;
+ $this->son->dad = $this; /* no segfault if this is commented out */
+ }
+ public function __destruct() {
+ $this->son = null;
+ parent::__destruct(); /* segfault here */
+ }
+}
+
+$o = new Dad;
+unset($o);
+echo "ok\n";
+?>
+--EXPECT--
+ok