@@ -128,7 +128,7 @@ int msgpack_convert_array(zval *return_value, zval *tpl, zval **value)
128128 zend_string * key ;
129129 int key_type ;
130130 ulong key_index ;
131- zval * data , * arydata ;
131+ zval * data , * arydata , nv , * nv_p ;
132132 HashPosition pos , valpos ;
133133 HashTable * ht , * htval ;
134134
@@ -188,22 +188,24 @@ int msgpack_convert_array(zval *return_value, zval *tpl, zval **value)
188188 zval_ptr_dtor (* value );
189189 return FAILURE ;
190190 }
191+ nv = * dataval ;
192+ nv_p = & nv ;
193+ zval_copy_ctor (& nv );
191194
192195 if (convert_function ) {
193196 zval rv ;
194- if (convert_function (& rv , data , & dataval ) != SUCCESS ) {
195- // zval_ptr_dtor(&val );
197+ if (convert_function (& rv , data , & nv_p ) != SUCCESS ) {
198+ zval_ptr_dtor (* value );
196199 return FAILURE ;
197200 }
198201 add_assoc_zval_ex (return_value , key -> val , key -> len , & rv );
199202 } else {
200- add_assoc_zval_ex (return_value , key -> val , key -> len , dataval );
203+ add_assoc_zval_ex (return_value , key -> val , key -> len , & nv );
201204 }
202205 }
203206 }
204207
205- //zval_ptr_dtor(*value);
206-
208+ zval_ptr_dtor (* value );
207209 return SUCCESS ;
208210 } else {
209211 /* index */
@@ -264,12 +266,15 @@ int msgpack_convert_array(zval *return_value, zval *tpl, zval **value)
264266 MSGPACK_WARNING ( "[msgpack] (%s) can't get next data in indexed array" , __FUNCTION__ );
265267 continue ;
266268 }
269+ nv = * arydata ;
270+ nv_p = & nv ;
271+ zval_copy_ctor (& nv );
267272
268273 switch (key_type ) {
269274 case HASH_KEY_IS_LONG : {
270275 zval rv ;
271276 if (convert_function ) {
272- if (convert_function (& rv , data , & arydata ) != SUCCESS ) {
277+ if (convert_function (& rv , data , & nv_p ) != SUCCESS ) {
273278 MSGPACK_WARNING (
274279 "[msgpack] (%s) "
275280 "convert failure in HASH_KEY_IS_LONG "
@@ -280,7 +285,7 @@ int msgpack_convert_array(zval *return_value, zval *tpl, zval **value)
280285 }
281286 add_next_index_zval (return_value , & rv );
282287 } else {
283- add_next_index_zval (return_value , arydata );
288+ add_next_index_zval (return_value , & nv );
284289 }
285290 break ;
286291 }
@@ -295,7 +300,7 @@ int msgpack_convert_array(zval *return_value, zval *tpl, zval **value)
295300 }
296301 }
297302
298- // zval_ptr_dtor(*value);
303+ zval_ptr_dtor (* value );
299304 return SUCCESS ;
300305 }
301306
@@ -307,10 +312,14 @@ int msgpack_convert_array(zval *return_value, zval *tpl, zval **value)
307312
308313int msgpack_convert_object (zval * return_value , zval * tpl , zval * * value ) {
309314 zend_class_entry * ce ;
315+ zend_string * tpl_zstring ;
310316
311317 switch (Z_TYPE_P (tpl )) {
312318 case IS_STRING :
313- if ((ce = zend_lookup_class (zval_get_string (tpl ))) == NULL ) {
319+ tpl_zstring = zval_get_string (tpl );
320+ ce = zend_lookup_class (tpl_zstring );
321+ zend_string_release (tpl_zstring );
322+ if (ce == NULL ) {
314323 MSGPACK_ERROR ("[msgpack] (%s) Class '%s' not found" ,
315324 __FUNCTION__ , Z_STRVAL_P (tpl ));
316325 return FAILURE ;
@@ -475,7 +484,7 @@ int msgpack_convert_object(zval *return_value, zval *tpl, zval **value) {
475484 num_key ++ ;
476485 } ZEND_HASH_FOREACH_END ();
477486 }
478- // zval_ptr_dtor(*value);
487+ zval_ptr_dtor (* value );
479488 break ;
480489 }
481490 default :
@@ -490,7 +499,7 @@ int msgpack_convert_object(zval *return_value, zval *tpl, zval **value) {
490499 MSGPACK_WARNING ("[msgpack] (%s) illegal offset type, skip this decoding" ,
491500 __FUNCTION__ );
492501 }
493- break ;
502+ zval_ptr_dtor ( * value ) ;
494503 }
495504 }
496505
0 commit comments