]> granicus.if.org Git - php/commitdiff
Fix leak when property AST evaluation fails
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 10 Oct 2019 10:44:55 +0000 (12:44 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 10 Oct 2019 10:44:55 +0000 (12:44 +0200)
Zend/tests/type_declarations/typed_properties_021.phpt
Zend/zend_API.c

index a9f82528d9260bbc9516dac95f28f1c17b5831a5..93a07771fba4eac0adc24bf524fe770a7128e789 100644 (file)
@@ -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
index 3fef3733f72b17c484b9e7148e148dd430a71f5a..8fab994297a6a1ceb91cd7f8f096afb98431db86 100644 (file)
@@ -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 */;