Skip to content

Commit adfa585

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fixed bug #81208
2 parents 65bbd92 + b976bc4 commit adfa585

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

ext/reflection/php_reflection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6623,7 +6623,7 @@ ZEND_METHOD(ReflectionAttribute, newInstance)
66236623
for (uint32_t i = 0; i < attr->data->argc; i++) {
66246624
zval val;
66256625
if (FAILURE == zend_get_attribute_value(&val, attr->data, i, attr->scope)) {
6626-
attribute_ctor_cleanup(&obj, args, i, named_params);
6626+
attribute_ctor_cleanup(&obj, args, argc, named_params);
66276627
RETURN_THROWS();
66286628
}
66296629
if (attr->data->args[i].name) {

ext/reflection/tests/bug81208.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Bug #81208: Segmentation fault while create newInstance from attribute
3+
--FILE--
4+
<?php
5+
6+
#[Attribute(Attribute::TARGET_PROPERTY)]
7+
class MyAnnotation
8+
{
9+
public function __construct(public bool $nullable = false) {}
10+
}
11+
12+
class MyClass {
13+
#[MyAnnotation(name: "my_name", type: "integer", nullable: asdasdasd)]
14+
public $property;
15+
}
16+
17+
$z = new ReflectionClass(MyClass::class);
18+
foreach ($z->getProperty("property")->getAttributes() as $attribute) {
19+
try {
20+
$attribute->newInstance();
21+
} catch (Error $e) {
22+
echo $e->getMessage(), "\n";
23+
}
24+
}
25+
26+
?>
27+
--EXPECT--
28+
Undefined constant "asdasdasd"

0 commit comments

Comments
 (0)