1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
The number of populated positional arguments is argc. i may also
include named args and thus try to dtor uninitialized zvals.
This commit is contained in:
Nikita Popov
2021-07-01 13:36:57 +02:00
parent 99c0efc77a
commit b976bc44f1
3 changed files with 33 additions and 1 deletions

4
NEWS
View File

@@ -22,6 +22,10 @@ PHP NEWS
- PCRE:
. Fixed bug #81101 (PCRE2 10.37 shows unexpected result). (Anatol)
- Reflection:
. Fixed bug #81208 (Segmentation fault while create newInstance from
attribute). (Nikita)
17 Jun 2021, PHP 8.0.8
- Core:

View File

@@ -6435,7 +6435,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) {

View 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"