1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix use-after-free of object released in hook

Fixes GH-16040
Closes GH-16058
This commit is contained in:
Ilija Tovilo
2024-09-25 17:50:56 +02:00
parent 97546746d0
commit 12844f96e2
3 changed files with 25 additions and 2 deletions

3
NEWS
View File

@@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.4.0RC2
- Core:
. Fixed bug GH-16040 (Use-after-free of object released in hook). (ilutov)
- DOM:
. Fixed bug GH-16039 (Segmentation fault (access null pointer) in
ext/dom/parentnode/tree.c). (nielsdos)

View File

@@ -0,0 +1,20 @@
--TEST--
GH-16040: Use-after-free of 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)

View File

@@ -828,8 +828,8 @@ try_again:
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);