Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Zend/tests/gh21603.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
GH-21603: Missing addref for __unset
--CREDITS--
cnwangjihe
--FILE--
<?php

class C {
public function __unset($name) {
global $c;
$c = null;
var_dump($this);
}
}

$c = new C;
unset($c->prop);

?>
--EXPECTF--
object(C)#%d (0) {
}
2 changes: 2 additions & 0 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1602,9 +1602,11 @@ ZEND_API void zend_std_unset_property(zend_object *zobj, zend_string *name, void
}
if (!((*guard) & IN_UNSET)) {
/* have unsetter - try with it! */
GC_ADDREF(zobj);
(*guard) |= IN_UNSET; /* prevent circular unsetting */
zend_std_call_unsetter(zobj, name);
(*guard) &= ~IN_UNSET;
OBJ_RELEASE(zobj);
return;
} else if (UNEXPECTED(IS_WRONG_PROPERTY_OFFSET(property_offset))) {
/* Trigger the correct error */
Expand Down
Loading