]> granicus.if.org Git - php/commitdiff
Fixed bug #77922
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 17 Aug 2019 08:57:26 +0000 (10:57 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Sat, 17 Aug 2019 08:58:54 +0000 (10:58 +0200)
In PHP 7.3 shadow properties are no longer duplicated. Make sure we
only release them if the property was defined on the parent class,
which means that it changed from private->shadow, which is where
duplication does happen.

NEWS
Zend/tests/bug77922.phpt [new file with mode: 0644]
Zend/zend_opcode.c

diff --git a/NEWS b/NEWS
index 07bd89152ac807a2b9faacd6853df115f295be03..9ddf7bcf83f25e00ec5ec0e419653b8ceb6ab989 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? ????, PHP 7.3.10
 
+- Core:
+  . Fixed bug #77922 (Double release of doc comment on inherited shadow
+    property). (Nikita)
+
 - Intl:
   . Ensure IDNA2003 rules are used with idn_to_ascii() and idn_to_utf8()
     when requested. (Sara)
diff --git a/Zend/tests/bug77922.phpt b/Zend/tests/bug77922.phpt
new file mode 100644 (file)
index 0000000..2984f4c
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+Bug #77922: Double release of doc comment on inherited shadow property
+--FILE--
+<?php
+
+class A {
+    /** Foo */
+    private $prop;
+}
+
+class B extends A {
+}
+
+class C extends B {
+}
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
index cd1525bdab99f02fd3c4203bded1057d19ee9bc8..a7f32de3798465cf9a4542539e22e550d5506fd5 100644 (file)
@@ -235,7 +235,8 @@ ZEND_API void destroy_zend_class(zval *zv)
                                efree(ce->default_static_members_table);
                        }
                        ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) {
-                               if (prop_info->ce == ce || (prop_info->flags & ZEND_ACC_SHADOW)) {
+                               if (prop_info->ce == ce ||
+                                               ((prop_info->flags & ZEND_ACC_SHADOW) && prop_info->ce == ce->parent)) {
                                        zend_string_release_ex(prop_info->name, 0);
                                        if (prop_info->doc_comment) {
                                                zend_string_release_ex(prop_info->doc_comment, 0);