mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Fixed bug #36006 (Problem with $this in __destruct())
This commit is contained in:
parent
4b1791a767
commit
b8360c376b
3 changed files with 33 additions and 0 deletions
1
NEWS
1
NEWS
|
@ -8,6 +8,7 @@ PHP NEWS
|
||||||
- Fixed bug #36016 (realpath cache memleaks). (Dmitry, Nuno)
|
- Fixed bug #36016 (realpath cache memleaks). (Dmitry, Nuno)
|
||||||
- Fixed bug #36011 (Strict errormsg wrong for call_user_func() and the likes).
|
- Fixed bug #36011 (Strict errormsg wrong for call_user_func() and the likes).
|
||||||
(Marcus)
|
(Marcus)
|
||||||
|
- Fixed bug #36006 (Problem with $this in __destruct()). (Dmitry)
|
||||||
- Fixed bug #35998 (SplFileInfo::getPathname() returns unix style filenames
|
- Fixed bug #35998 (SplFileInfo::getPathname() returns unix style filenames
|
||||||
in win32). (Marcus)
|
in win32). (Marcus)
|
||||||
|
|
||||||
|
|
30
Zend/tests/bug36006.phpt
Executable file
30
Zend/tests/bug36006.phpt
Executable file
|
@ -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
|
|
@ -52,7 +52,9 @@ ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TS
|
||||||
if (!objects->object_buckets[i].destructor_called) {
|
if (!objects->object_buckets[i].destructor_called) {
|
||||||
objects->object_buckets[i].destructor_called = 1;
|
objects->object_buckets[i].destructor_called = 1;
|
||||||
if (obj->dtor && obj->object) {
|
if (obj->dtor && obj->object) {
|
||||||
|
obj->refcount++;
|
||||||
obj->dtor(obj->object, i TSRMLS_CC);
|
obj->dtor(obj->object, i TSRMLS_CC);
|
||||||
|
obj->refcount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue