Skip to content

Commit 2965b24

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Check object_init_ex() in ReflectionMethod::createFromMethodName()
2 parents cc0ff7e + b80ef09 commit 2965b24

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

ext/reflection/php_reflection.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3392,7 +3392,10 @@ static void instantiate_reflection_method(INTERNAL_FUNCTION_PARAMETERS, bool is_
33923392
if (is_constructor) {
33933393
object = ZEND_THIS;
33943394
} else {
3395-
object_init_ex(return_value, execute_data->This.value.ce ? execute_data->This.value.ce : reflection_method_ptr);
3395+
zend_class_entry *called_ce = execute_data->This.value.ce ? execute_data->This.value.ce : reflection_method_ptr;
3396+
if (UNEXPECTED(object_init_ex(return_value, called_ce) != SUCCESS)) {
3397+
RETURN_THROWS();
3398+
}
33963399
object = return_value;
33973400
}
33983401
intern = Z_REFLECTION_P(object);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
ReflectionMethod::createFromMethodName() called on an abstract subclass
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function a() {}
8+
}
9+
10+
abstract class R extends ReflectionMethod {}
11+
12+
try {
13+
R::createFromMethodName('C::a');
14+
} catch (Throwable $e) {
15+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
16+
}
17+
18+
var_dump(ReflectionMethod::createFromMethodName('C::a')->name);
19+
20+
?>
21+
--EXPECT--
22+
Error: Cannot instantiate abstract class R
23+
string(1) "a"

0 commit comments

Comments
 (0)