Skip to content

Commit be9f26d

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix missing addref for __unset
2 parents a82696d + 6c5bed3 commit be9f26d

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ PHP NEWS
1313
. Fixed bug GH-21605 (Missing addref for Countable::count()). (ilutov)
1414
. Fixed bug GH-21699 (Assertion failure in shutdown_executor when resolving
1515
self::/parent::/static:: callables if the error handler throws). (macoaure)
16+
. Fixed bug GH-21603 (Missing addref for __unset). (ilutov)
1617

1718
- Curl:
1819
. Add support for brotli and zstd on Windows. (Shivam Mathur)

Zend/tests/gh21603.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-21603: Missing addref for __unset
3+
--CREDITS--
4+
cnwangjihe
5+
--FILE--
6+
<?php
7+
8+
class C {
9+
public function __unset($name) {
10+
global $c;
11+
$c = null;
12+
var_dump($this);
13+
}
14+
}
15+
16+
$c = new C;
17+
unset($c->prop);
18+
19+
?>
20+
--EXPECTF--
21+
object(C)#%d (0) {
22+
}

Zend/zend_object_handlers.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,9 +1657,11 @@ ZEND_API void zend_std_unset_property(zend_object *zobj, zend_string *name, void
16571657
}
16581658
if (!((*guard) & IN_UNSET)) {
16591659
/* have unsetter - try with it! */
1660+
GC_ADDREF(zobj);
16601661
(*guard) |= IN_UNSET; /* prevent circular unsetting */
16611662
zend_std_call_unsetter(zobj, name);
16621663
(*guard) &= ~IN_UNSET;
1664+
OBJ_RELEASE(zobj);
16631665
return;
16641666
} else if (UNEXPECTED(IS_WRONG_PROPERTY_OFFSET(property_offset))) {
16651667
/* Trigger the correct error */

0 commit comments

Comments
 (0)