Skip to content

Commit

Permalink
Fix usage of casted string in ReflectionParameter ctor
Browse files Browse the repository at this point in the history
Fixes oss-fuzz #27755.
  • Loading branch information
nikic committed Nov 24, 2020
1 parent d016434 commit 706241f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -2306,10 +2306,10 @@ ZEND_METHOD(reflection_parameter, __construct)
/* nothing to do. don't set is_closure since is the invoke handler,
not the closure itself */
} else if ((fptr = zend_hash_find_ptr(&ce->function_table, lcname)) == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Method %s::%s() does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(name));
zend_string_release(name);
zend_string_release(lcname);
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Method %s::%s() does not exist", ZSTR_VAL(ce->name), Z_STRVAL_P(method));
return;
}
zend_string_release(name);
Expand Down
18 changes: 18 additions & 0 deletions ext/reflection/tests/ReflectionParameter_ctor_cast.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Test method name string cast in ReflectionParameter ctor
--FILE--
<?php

class A {}
try {
new ReflectionParameter([
A::class,
new class { public function __toString() { return 'method'; } }
], 'param');
} catch (ReflectionException $e) {
echo $e->getMessage(), "\n";
}

?>
--EXPECT--
Method A::method() does not exist

0 comments on commit 706241f

Please sign in to comment.