summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--Zend/tests/inherit_internal_static.phpt18
-rw-r--r--Zend/zend_inheritance.c3
-rw-r--r--Zend/zend_object_handlers.c6
-rw-r--r--Zend/zend_object_handlers.h1
5 files changed, 27 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 5f32b5a924..2a77346cc2 100644
--- 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
index 0000000000..4716717f15
--- /dev/null
+++ b/Zend/tests/inherit_internal_static.phpt
@@ -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)
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index f3b62ef7e5..eed2074729 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -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);
}
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 6d9156b1a1..7d200402a9 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -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) {
diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h
index e35074c33a..acc4b7575f 100644
--- a/Zend/zend_object_handlers.h
+++ b/Zend/zend_object_handlers.h
@@ -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);