@@ -35,25 +35,7 @@ zend_object_handlers IntlIterator_handlers;
35
35
void zoi_with_current_dtor (zend_object_iterator *iter)
36
36
{
37
37
zoi_with_current *zoiwc = (zoi_with_current*)iter;
38
-
39
- if (!Z_ISUNDEF (zoiwc->wrapping_obj )) {
40
- /* we have to copy the pointer because zoiwc->wrapping_obj may be
41
- * changed midway the execution of zval_ptr_dtor() */
42
- zval *zwo = &zoiwc->wrapping_obj ;
43
-
44
- /* object is still here, we can rely on it to call this again and
45
- * destroy this object */
46
- zval_ptr_dtor (zwo);
47
- } else {
48
- /* Object not here anymore (we've been called by the object free handler)
49
- * Note that the iterator wrapper objects (that also depend on this
50
- * structure) call this function earlier, in the destruction phase, which
51
- * precedes the object free phase. Therefore there's no risk on this
52
- * function being called by the iterator wrapper destructor function and
53
- * not finding the memory of this iterator allocated anymore. */
54
- iter->funcs ->invalidate_current (iter);
55
- zoiwc->destroy_it (iter);
56
- }
38
+ zval_ptr_dtor (&zoiwc->wrapping_obj );
57
39
}
58
40
59
41
U_CFUNC zend_result zoi_with_current_valid (zend_object_iterator *iter)
@@ -124,6 +106,7 @@ static void string_enum_rewind(zend_object_iterator *iter)
124
106
static void string_enum_destroy_it (zend_object_iterator *iter)
125
107
{
126
108
delete (StringEnumeration*)Z_PTR (iter->data );
109
+ efree (iter);
127
110
}
128
111
129
112
static const zend_object_iterator_funcs string_enum_object_iterator_funcs = {
@@ -148,7 +131,7 @@ U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *ob
148
131
ii->iterator ->funcs = &string_enum_object_iterator_funcs;
149
132
ii->iterator ->index = 0 ;
150
133
((zoi_with_current*)ii->iterator )->destroy_it = string_enum_destroy_it;
151
- ZVAL_OBJ (&((zoi_with_current*)ii->iterator )->wrapping_obj , Z_OBJ_P (object));
134
+ ZVAL_OBJ_COPY (&((zoi_with_current*)ii->iterator )->wrapping_obj , Z_OBJ_P (object));
152
135
ZVAL_UNDEF (&((zoi_with_current*)ii->iterator )->current );
153
136
}
154
137
@@ -157,9 +140,7 @@ static void IntlIterator_objects_free(zend_object *object)
157
140
IntlIterator_object *ii = php_intl_iterator_fetch_object (object);
158
141
159
142
if (ii->iterator ) {
160
- zval *wrapping_objp = &((zoi_with_current*)ii->iterator )->wrapping_obj ;
161
- ZVAL_UNDEF (wrapping_objp);
162
- zend_iterator_dtor (ii->iterator );
143
+ ((zoi_with_current*)ii->iterator )->destroy_it (ii->iterator );
163
144
}
164
145
intl_error_reset (INTLITERATOR_ERROR_P (ii));
165
146
0 commit comments