mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
commit
adfa585109
2 changed files with 29 additions and 1 deletions
|
@ -6623,7 +6623,7 @@ ZEND_METHOD(ReflectionAttribute, newInstance)
|
|||
for (uint32_t i = 0; i < attr->data->argc; i++) {
|
||||
zval val;
|
||||
if (FAILURE == zend_get_attribute_value(&val, attr->data, i, attr->scope)) {
|
||||
attribute_ctor_cleanup(&obj, args, i, named_params);
|
||||
attribute_ctor_cleanup(&obj, args, argc, named_params);
|
||||
RETURN_THROWS();
|
||||
}
|
||||
if (attr->data->args[i].name) {
|
||||
|
|
28
ext/reflection/tests/bug81208.phpt
Normal file
28
ext/reflection/tests/bug81208.phpt
Normal file
|
@ -0,0 +1,28 @@
|
|||
--TEST--
|
||||
Bug #81208: Segmentation fault while create newInstance from attribute
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
#[Attribute(Attribute::TARGET_PROPERTY)]
|
||||
class MyAnnotation
|
||||
{
|
||||
public function __construct(public bool $nullable = false) {}
|
||||
}
|
||||
|
||||
class MyClass {
|
||||
#[MyAnnotation(name: "my_name", type: "integer", nullable: asdasdasd)]
|
||||
public $property;
|
||||
}
|
||||
|
||||
$z = new ReflectionClass(MyClass::class);
|
||||
foreach ($z->getProperty("property")->getAttributes() as $attribute) {
|
||||
try {
|
||||
$attribute->newInstance();
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Undefined constant "asdasdasd"
|
Loading…
Add table
Add a link
Reference in a new issue