@@ -152,22 +152,42 @@ ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce)
152
152
zval * static_members = CE_STATIC_MEMBERS (ce );
153
153
zval * p = static_members ;
154
154
zval * end = p + ce -> default_static_members_count ;
155
-
156
- ZEND_MAP_PTR_SET (ce -> static_members_table , NULL );
157
- while (p != end ) {
158
- if (UNEXPECTED (Z_ISREF_P (p ))) {
159
- zend_property_info * prop_info ;
160
- ZEND_REF_FOREACH_TYPE_SOURCES (Z_REF_P (p ), prop_info ) {
161
- if (prop_info -> ce == ce && p - static_members == prop_info -> offset ) {
162
- ZEND_REF_DEL_TYPE_SOURCE (Z_REF_P (p ), prop_info );
163
- break ; /* stop iteration here, the array might be realloc()'ed */
164
- }
165
- } ZEND_REF_FOREACH_TYPE_SOURCES_END ();
155
+ if (UNEXPECTED (ZEND_MAP_PTR (ce -> static_members_table ) == & ce -> default_static_members_table )) {
156
+ /* Special case: If this is a static property on a dl'ed internal class, then the
157
+ * static property table and the default property table are the same. In this case we
158
+ * destroy the values here, but leave behind valid UNDEF zvals and don't free the
159
+ * table itself. */
160
+ while (p != end ) {
161
+ if (UNEXPECTED (Z_ISREF_P (p ))) {
162
+ zend_property_info * prop_info ;
163
+ ZEND_REF_FOREACH_TYPE_SOURCES (Z_REF_P (p ), prop_info ) {
164
+ if (prop_info -> ce == ce && p - static_members == prop_info -> offset ) {
165
+ ZEND_REF_DEL_TYPE_SOURCE (Z_REF_P (p ), prop_info );
166
+ break ; /* stop iteration here, the array might be realloc()'ed */
167
+ }
168
+ } ZEND_REF_FOREACH_TYPE_SOURCES_END ();
169
+ }
170
+ i_zval_ptr_dtor (p );
171
+ ZVAL_UNDEF (p );
172
+ p ++ ;
173
+ }
174
+ } else {
175
+ ZEND_MAP_PTR_SET (ce -> static_members_table , NULL );
176
+ while (p != end ) {
177
+ if (UNEXPECTED (Z_ISREF_P (p ))) {
178
+ zend_property_info * prop_info ;
179
+ ZEND_REF_FOREACH_TYPE_SOURCES (Z_REF_P (p ), prop_info ) {
180
+ if (prop_info -> ce == ce && p - static_members == prop_info -> offset ) {
181
+ ZEND_REF_DEL_TYPE_SOURCE (Z_REF_P (p ), prop_info );
182
+ break ; /* stop iteration here, the array might be realloc()'ed */
183
+ }
184
+ } ZEND_REF_FOREACH_TYPE_SOURCES_END ();
185
+ }
186
+ i_zval_ptr_dtor (p );
187
+ p ++ ;
166
188
}
167
- i_zval_ptr_dtor (p );
168
- p ++ ;
189
+ efree (static_members );
169
190
}
170
- efree (static_members );
171
191
}
172
192
}
173
193
0 commit comments