Skip to content

Commit

Permalink
Fixed bug #36006 (Problem with $this in __destruct())
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Jan 16, 2006
1 parent 7e5b53c commit c93396a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
30 changes: 30 additions & 0 deletions 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
2 changes: 2 additions & 0 deletions Zend/zend_objects_API.c
Expand Up @@ -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->object) {
obj->refcount++;
obj->dtor(obj->object, i TSRMLS_CC);
obj->refcount--;
}
}
}
Expand Down

0 comments on commit c93396a

Please sign in to comment.