@@ -35,25 +35,7 @@ zend_object_handlers IntlIterator_handlers;
3535void  zoi_with_current_dtor (zend_object_iterator *iter)
3636{
3737	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 );
5739}
5840
5941U_CFUNC zend_result zoi_with_current_valid (zend_object_iterator *iter)
@@ -124,6 +106,7 @@ static void string_enum_rewind(zend_object_iterator *iter)
124106static  void  string_enum_destroy_it (zend_object_iterator *iter)
125107{
126108	delete  (StringEnumeration*)Z_PTR (iter->data );
109+ 	efree (iter);
127110}
128111
129112static  const  zend_object_iterator_funcs string_enum_object_iterator_funcs = {
@@ -148,7 +131,7 @@ U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *ob
148131	ii->iterator ->funcs  = &string_enum_object_iterator_funcs;
149132	ii->iterator ->index  = 0 ;
150133	((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));
152135	ZVAL_UNDEF (&((zoi_with_current*)ii->iterator )->current );
153136}
154137
@@ -157,9 +140,7 @@ static void IntlIterator_objects_free(zend_object *object)
157140	IntlIterator_object	*ii = php_intl_iterator_fetch_object (object);
158141
159142	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 );
163144	}
164145	intl_error_reset (INTLITERATOR_ERROR_P (ii));
165146
0 commit comments