]> granicus.if.org Git - php/commitdiff
Fixed bug #77498
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 25 Jan 2019 10:00:35 +0000 (11:00 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 25 Jan 2019 10:01:06 +0000 (11:01 +0100)
I've renamed the function to the same name as the exported symbol
in master.

NEWS
Zend/tests/inherit_internal_static.phpt [new file with mode: 0644]
Zend/zend_inheritance.c
Zend/zend_object_handlers.c
Zend/zend_object_handlers.h

diff --git a/NEWS b/NEWS
index 5f32b5a924639270fa91347e61332882682d539e..2a77346cc29455c2e4454ff04b288d3ec4089b08 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP                                                                        NEWS
 - Core:
   . Fixed bug #77494 (Disabling class causes segfault on member access).
     (Dmitry)
+  . Fixed bug #77498 (Custom extension Segmentation fault when declare static
+    property). (Nikita)
 
 - Mbstring:
   . Fixed bug #77514 (mb_ereg_replace() with trailing backslash adds null byte).
diff --git a/Zend/tests/inherit_internal_static.phpt b/Zend/tests/inherit_internal_static.phpt
new file mode 100644 (file)
index 0000000..4716717
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Inherit internal static property into userland class
+--SKIPIF--
+<?php if (!extension_loaded('zend-test')) die('skip requires zend-test'); ?>
+--FILE--
+<?php
+
+class Test extends _ZendTestClass {
+}
+
+var_dump(Test::$_StaticProp);
+_ZendTestClass::$_StaticProp = 42;
+var_dump(Test::$_StaticProp);
+
+?>
+--EXPECT--
+NULL
+int(42)
index f3b62ef7e58bd88067c10113a9db6feec0c42baf..eed2074729116c17ffd52c9f0783ba925beb4045 100644 (file)
@@ -894,6 +894,9 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent
                }
                if (UNEXPECTED(parent_ce->type != ce->type)) {
                        /* User class extends internal */
+                       if (CE_STATIC_MEMBERS(parent_ce) == NULL) {
+                               zend_class_init_statics(parent_ce);
+                       }
                        if (UNEXPECTED(zend_update_class_constants(parent_ce) != SUCCESS)) {
                                ZEND_ASSERT(0);
                        }
index 6d9156b1a1dade10fff36b9bf53f0e6379730df2..7d200402a92c64440a2fa07cc9bad637fe5f6531 100644 (file)
@@ -1374,14 +1374,14 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
 }
 /* }}} */
 
-static void zend_intenal_class_init_statics(zend_class_entry *class_type) /* {{{ */
+ZEND_API void zend_class_init_statics(zend_class_entry *class_type) /* {{{ */
 {
        int i;
        zval *p;
 
        if (!CE_STATIC_MEMBERS(class_type) && class_type->default_static_members_count) {
                if (class_type->parent) {
-                       zend_intenal_class_init_statics(class_type->parent);
+                       zend_class_init_statics(class_type->parent);
                }
 
 #if ZTS
@@ -1431,7 +1431,7 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p
        /* check if static properties were destoyed */
        if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) {
                if (ce->type == ZEND_INTERNAL_CLASS) {
-                       zend_intenal_class_init_statics(ce);
+                       zend_class_init_statics(ce);
                } else {
 undeclared_property:
                        if (!silent) {
index e35074c33a9d0ef0332238aacca3383843055133..acc4b7575f9822e66df33fdd38a88a76d7fea471 100644 (file)
@@ -175,6 +175,7 @@ extern const ZEND_API zend_object_handlers std_object_handlers;
 #define ZEND_PROPERTY_NOT_EMPTY ZEND_ISEMPTY /* Property is not empty */
 #define ZEND_PROPERTY_EXISTS    0x2          /* Property exists */
 
+ZEND_API void zend_class_init_statics(zend_class_entry *ce);
 ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const zval *key);
 ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, zend_bool silent);
 ZEND_API ZEND_COLD zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name);