com php-src: Fix leak when property AST evaluation fails: Zend/tests/type_declarations/typed_properties_021 .phpt Zend/zend_API.c
| From: | Nikita Popov | Date: | Thu, 10 Oct 2019 10:44:55 +0000 |
| Subject: | com php-src: Fix leak when property AST evaluation fails: Zend/tests/type_declarations/typed_properties_021 .phpt Zend/zend_API.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-108860@lists.php.net to get a copy of this message | ||
Commit: 12f4e9e020c3968c5a201ef96c4ee589ad36e5e5
Author: Nikita Popov <nikita.ppv@gmail.com> Thu, 10 Oct 2019 12:44:55 +0200
Parents: f43f493e09b28d8d3924fbcea2392108ca7f5f65
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=12f4e9e020c3968c5a201ef96c4ee589ad36e5e5
Log:
Fix leak when property AST evaluation fails
Changed paths:
M Zend/tests/type_declarations/typed_properties_021.phpt
M Zend/zend_API.c
Diff:
diff --git a/Zend/tests/type_declarations/typed_properties_021.phpt
b/Zend/tests/type_declarations/typed_properties_021.phpt
index a9f82528d92..93a07771fba 100644
--- a/Zend/tests/type_declarations/typed_properties_021.phpt
+++ b/Zend/tests/type_declarations/typed_properties_021.phpt
@@ -6,10 +6,11 @@ class Foo {
public int $bar = BAR::BAZ;
}
-$foo = new Foo();
+try {
+ $foo = new Foo();
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
?>
---EXPECTF--
-Fatal error: Uncaught Error: Class 'BAR' not found in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+--EXPECT--
+Class 'BAR' not found
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 3fef3733f72..8fab994297a 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -1228,6 +1228,7 @@ ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{
*/
ZVAL_COPY(&tmp, val);
if (UNEXPECTED(zval_update_constant_ex(&tmp, ce) != SUCCESS)) {
+ zval_ptr_dtor(&tmp);
return FAILURE;
}
/* property initializers must always be evaluated with strict types */;