Skip to content

Commit 12f4e9e

Browse files
committed
Fix leak when property AST evaluation fails
1 parent f43f493 commit 12f4e9e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Zend/tests/type_declarations/typed_properties_021.phpt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ class Foo {
66
public int $bar = BAR::BAZ;
77
}
88

9-
$foo = new Foo();
9+
try {
10+
$foo = new Foo();
11+
} catch (Error $e) {
12+
echo $e->getMessage(), "\n";
13+
}
1014
?>
11-
--EXPECTF--
12-
Fatal error: Uncaught Error: Class 'BAR' not found in %s:%d
13-
Stack trace:
14-
#0 {main}
15-
thrown in %s on line %d
15+
--EXPECT--
16+
Class 'BAR' not found

Zend/zend_API.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,7 @@ ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */
12281228

12291229
ZVAL_COPY(&tmp, val);
12301230
if (UNEXPECTED(zval_update_constant_ex(&tmp, ce) != SUCCESS)) {
1231+
zval_ptr_dtor(&tmp);
12311232
return FAILURE;
12321233
}
12331234
/* property initializers must always be evaluated with strict types */;

0 commit comments

Comments
 (0)