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
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ PHP NEWS
. Fixed bug GH-24729 (Use-after-free in
ReflectionClass::setStaticPropertyValue() when the old value's destructor
unbinds the property). (Lazizbek Ergashev)
. Fixed bug GH-26099 (Use-after-free in ReflectionParameter when constructed
from a closure's __invoke after the closure is freed). (Lazizbek Ergashev)

- Standard:
. Fixed bug GH-25959 ("consumed" stream filter loses or repeats data).
Expand Down
5 changes: 3 additions & 2 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -2580,8 +2580,9 @@ ZEND_METHOD(ReflectionParameter, __construct)
if (Z_TYPE_P(classref) == IS_OBJECT && is_closure_invoke(ce, lcname)
&& (fptr = zend_get_closure_invoke_method(Z_OBJ_P(classref))) != NULL)
{
/* nothing to do. don't set is_closure since is the invoke handler,
not the closure itself */
reference = classref;
Z_ADDREF_P(reference);
is_closure = true;
} else if ((fptr = zend_hash_find_ptr(&ce->function_table, lcname)) == NULL) {
// %S is used for zend_string pointers by smart str printing, but normally
// is for wide character strings and so compilers complain if this is inline
Expand Down
13 changes: 13 additions & 0 deletions ext/reflection/tests/gh26099.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
GH-26099 (ReflectionParameter::getType() UAF when a closure's __invoke trampoline outlives the closure)
--CREDITS--
br1p4v3s1
--FILE--
<?php
$fn = eval('class Foo {} return function (Foo $a) {};');
$p = new ReflectionParameter([$fn, '__invoke'], 0);
unset($fn);
var_dump($p->getType()->getName());
?>
--EXPECT--
string(3) "Foo"
Loading