Patch fix-refs-to-default-static-members for Scripting Engine problem Bug #51581
Patch version 2010-05-12 13:42 UTC
Return to Bug #51581 |
Download this patch
Patch Revisions:
Developer: mike@php.net
Index: Zend/zend_API.c
===================================================================
--- Zend/zend_API.c (revision 299276)
+++ Zend/zend_API.c (working copy)
@@ -999,7 +999,7 @@
ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
- if (!class_type->constants_updated || !CE_STATIC_MEMBERS(class_type)) {
+ if (!class_type->constants_updated || !CE_STATIC_MEMBERS(class_type) || (class_type->type == ZEND_USER_CLASS && class_type->static_members == &class_type->default_static_members)) {
zend_class_entry **scope = EG(in_execution)?&EG(scope):&CG(active_class_entry);
zend_class_entry *old_scope = *scope;
@@ -1007,18 +1007,15 @@
zend_hash_apply_with_argument(&class_type->constants_table, (apply_func_arg_t) zval_update_constant, (void*)1 TSRMLS_CC);
zend_hash_apply_with_argument(&class_type->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
- if (!CE_STATIC_MEMBERS(class_type)) {
+ if (!CE_STATIC_MEMBERS(class_type) || (class_type->type == ZEND_USER_CLASS && class_type->static_members == &class_type->default_static_members)) {
HashPosition pos;
zval **p;
if (class_type->parent) {
zend_update_class_constants(class_type->parent TSRMLS_CC);
}
-#if ZTS
- ALLOC_HASHTABLE(CG(static_members)[(zend_intptr_t)(class_type->static_members)]);
-#else
- ALLOC_HASHTABLE(class_type->static_members);
-#endif
+
+ ALLOC_HASHTABLE(CE_STATIC_MEMBERS(class_type));
zend_hash_init(CE_STATIC_MEMBERS(class_type), zend_hash_num_elements(&class_type->default_static_members), NULL, ZVAL_PTR_DTOR, 0);
zend_hash_internal_pointer_reset_ex(&class_type->default_static_members, &pos);
Index: Zend/zend_opcode.c
===================================================================
--- Zend/zend_opcode.c (revision 299276)
+++ Zend/zend_opcode.c (working copy)
@@ -159,6 +159,10 @@
/* Note that only run-time accessed data need to be cleaned up, pre-defined data can
not contain objects and thus are not probelmatic */
zend_hash_apply(&(*pce)->function_table, (apply_func_t) zend_cleanup_function_data_full TSRMLS_CC);
+ if ((*pce)->static_members && (*pce)->static_members != &(*pce)->default_static_members) {
+ zend_hash_destroy((*pce)->static_members);
+ FREE_HASHTABLE((*pce)->static_members);
+ }
(*pce)->static_members = NULL;
} else if (CE_STATIC_MEMBERS(*pce)) {
zend_hash_destroy(CE_STATIC_MEMBERS(*pce));
|