summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-01-16 10:13:12 +0000
committerDmitry Stogov <dmitry@php.net>2006-01-16 10:13:12 +0000
commit12f2e71609f188bc4ab70d26e48a4de4a3b50b6a (patch)
tree54d77e920e24d29bf380e4c33d9227724a2c0413
parent06ffd2f72edaadabdd082cd8444ec11f8fc4bd69 (diff)
downloadphp-git-12f2e71609f188bc4ab70d26e48a4de4a3b50b6a.tar.gz
Fixed bug #36006 (Problem with $this in __destruct())
-rw-r--r--NEWS1
-rwxr-xr-xZend/tests/bug36006.phpt30
-rw-r--r--Zend/zend_objects_API.c2
3 files changed, 33 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 10cf07c493..0a2b372ce7 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ PHP NEWS
- Fixed an error in mysqli_fetch_fields (returned NULL instead of an
array when row number > field_count). (Georg)
- Renamed CachingRecursiveIterator to RecursiveCachingIterator. (Marcus)
+- Fixed bug #36006 (Problem with $this in __destruct()). (Dmitry)
- Fixed bug #35612 (iis6 Access Violation crash). (Dmitry, alacn.uhahaa)
- Fixed bug #35570 (segfault when re-using soap client object). (Dmitry)
- FIxed bug #35536 (mysql_field_type() doesn't handle NEWDECIMAL). (Tony)
diff --git a/Zend/tests/bug36006.phpt b/Zend/tests/bug36006.phpt
new file mode 100755
index 0000000000..79f9897d13
--- /dev/null
+++ b/Zend/tests/bug36006.phpt
@@ -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
diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c
index 02b6a36263..d2320805c9 100644
--- a/Zend/zend_objects_API.c
+++ b/Zend/zend_objects_API.c
@@ -52,7 +52,9 @@ ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TS
if (!objects->object_buckets[i].destructor_called) {
objects->object_buckets[i].destructor_called = 1;
if (obj->dtor) {
+ obj->refcount++;
obj->dtor(obj->object, i TSRMLS_CC);
+ obj->refcount--;
}
}
}