Skip to content
Closed
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
20 changes: 20 additions & 0 deletions Zend/tests/property_hooks/gh16040.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
GH-16040: Use-after-free on object released in hook
--FILE--
<?php

class A {
public $bar {
get {
$GLOBALS['a'] = null;
return 42;
}
}
}

$a = new A();
var_dump($a->bar);

?>
--EXPECT--
int(42)
4 changes: 2 additions & 2 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,8 +828,8 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int

if (EXPECTED(cache_slot
&& zend_execute_ex == execute_ex
&& zobj->ce->default_object_handlers->read_property == zend_std_read_property
&& !zobj->ce->create_object
&& ce->default_object_handlers->read_property == zend_std_read_property
&& !ce->create_object
&& !zend_is_in_hook(prop_info)
&& !(prop_info->hooks[ZEND_PROPERTY_HOOK_GET]->common.fn_flags & ZEND_ACC_RETURN_REFERENCE))) {
ZEND_SET_PROPERTY_HOOK_SIMPLE_GET(cache_slot);
Expand Down
Loading