@@ -170,7 +170,7 @@ typedef struct {
170
170
} php_memc_t ;
171
171
172
172
static inline php_memc_t * php_memc_fetch_object (zend_object * obj ) {
173
- return (php_memc_t * )((char * )( obj ) - XtOffsetOf (php_memc_t , zo ));
173
+ return (php_memc_t * )((char * )obj - XtOffsetOf (php_memc_t , zo ));
174
174
}
175
175
#define Z_MEMC_OBJ_P (zv ) php_memc_fetch_object(Z_OBJ_P(zv));
176
176
@@ -356,20 +356,17 @@ char *php_memc_printable_func (zend_fcall_info *fci, zend_fcall_info_cache *fci_
356
356
static zend_bool php_memcached_on_new_callback (zval * object , zend_fcall_info * fci , zend_fcall_info_cache * fci_cache , zend_string * persistent_id )
357
357
{
358
358
zend_bool ret = 1 ;
359
- zval retval ;
360
- zval params [2 ];
359
+ zval retval , id ;
361
360
362
361
if (persistent_id ) {
363
- ZVAL_STR (& params [ 1 ] , persistent_id );
362
+ ZVAL_STR (& id , persistent_id );
364
363
} else {
365
- ZVAL_NULL (& params [ 1 ] );
364
+ ZVAL_NULL (& id );
366
365
}
367
366
368
- /* Call the cb */
369
- ZVAL_COPY (& params [0 ], object );
367
+ ZVAL_UNDEF (& retval );
370
368
371
- fci -> params = params ;
372
- fci -> param_count = 2 ;
369
+ zend_fcall_info_argn (fci , 2 , object , & id );
373
370
fci -> retval = & retval ;
374
371
fci -> no_separation = 1 ;
375
372
@@ -379,10 +376,12 @@ static zend_bool php_memcached_on_new_callback(zval *object, zend_fcall_info *fc
379
376
efree (buf );
380
377
ret = 0 ;
381
378
}
379
+
380
+ if (Z_TYPE (retval ) != IS_UNDEF )
381
+ zval_ptr_dtor (& retval );
382
+
383
+ zend_fcall_info_args_clear (fci , 1 );
382
384
383
- zval_ptr_dtor (& params [0 ]);
384
- zval_ptr_dtor (& params [1 ]);
385
- zval_ptr_dtor (& retval );
386
385
return ret ;
387
386
}
388
387
@@ -407,7 +406,7 @@ static PHP_METHOD(Memcached, __construct)
407
406
zend_fcall_info fci = {0 };
408
407
zend_fcall_info_cache fci_cache ;
409
408
410
- if (zend_parse_parameters_throw (ZEND_NUM_ARGS (), "|S!f!S" , & persistent_id , & fci , & fci_cache , & conn_str ) == FAILURE ) {
409
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "|S!f!S" , & persistent_id , & fci , & fci_cache , & conn_str ) == FAILURE ) {
411
410
return ;
412
411
}
413
412
@@ -3295,6 +3294,7 @@ zend_bool s_unserialize_value (enum memcached_serializer serializer, int val_typ
3295
3294
3296
3295
PHP_VAR_UNSERIALIZE_INIT (var_hash );
3297
3296
if (!php_var_unserialize (value , (const unsigned char * * )& payload_tmp , (const unsigned char * )payload_tmp + payload_len , & var_hash )) {
3297
+ zval_ptr_dtor (value );
3298
3298
ZVAL_FALSE (value );
3299
3299
PHP_VAR_UNSERIALIZE_DESTROY (var_hash );
3300
3300
php_error_docref (NULL , E_WARNING , "could not unserialize value" );
@@ -3529,6 +3529,7 @@ static memcached_return php_memc_do_cache_callback(zval *zmemc_obj, zend_fcall_i
3529
3529
fci -> param_count = 4 ;
3530
3530
3531
3531
result = zend_call_function (fci , fcc );
3532
+
3532
3533
ZVAL_DUP (value , Z_REFVAL (z_val ));
3533
3534
expiration = Z_REFVAL (z_expiration );
3534
3535
if (result == SUCCESS && Z_TYPE (retval ) != IS_UNDEF ) {
@@ -3573,6 +3574,7 @@ static memcached_return php_memc_do_cache_callback(zval *zmemc_obj, zend_fcall_i
3573
3574
zval_ptr_dtor (& z_key );
3574
3575
zval_ptr_dtor (& z_val );
3575
3576
zval_ptr_dtor (& z_expiration );
3577
+ zval_ptr_dtor (zmemc_obj );
3576
3578
3577
3579
return status ;
3578
3580
}
@@ -3594,9 +3596,7 @@ static int php_memc_do_result_callback(zval *zmemc_obj, zend_fcall_info *fci,
3594
3596
int rc = 0 ;
3595
3597
php_memc_t * i_obj = NULL ;
3596
3598
3597
- ZVAL_COPY (& params [0 ], zmemc_obj );
3598
3599
fci -> retval = & retval ;
3599
- fci -> params = params ;
3600
3600
fci -> param_count = 2 ;
3601
3601
3602
3602
payload = memcached_result_value (result );
@@ -3615,7 +3615,6 @@ static int php_memc_do_result_callback(zval *zmemc_obj, zend_fcall_info *fci,
3615
3615
}
3616
3616
3617
3617
array_init (& z_result );
3618
- ZVAL_COPY (& params [1 ], & z_result );
3619
3618
add_assoc_stringl_ex (& z_result , ZEND_STRL ("key" ), (char * )res_key , res_key_len );
3620
3619
add_assoc_zval_ex (& z_result , ZEND_STRL ("value" ), & value );
3621
3620
if (cas != 0 ) {
@@ -3625,16 +3624,19 @@ static int php_memc_do_result_callback(zval *zmemc_obj, zend_fcall_info *fci,
3625
3624
add_assoc_long_ex (& z_result , ZEND_STRL ("flags" ), MEMC_VAL_GET_USER_FLAGS (flags ));
3626
3625
}
3627
3626
3627
+ ZVAL_UNDEF (& retval );
3628
+ zend_fcall_info_argn (fci , 2 , zmemc_obj , & z_result );
3629
+
3628
3630
if (zend_call_function (fci , fcc ) == FAILURE ) {
3629
3631
php_error_docref (NULL , E_WARNING , "could not invoke result callback" );
3630
3632
rc = -1 ;
3631
3633
}
3632
3634
3633
- if (& retval ) {
3635
+ if (Z_TYPE ( retval ) != IS_UNDEF ) {
3634
3636
zval_ptr_dtor (& retval );
3635
3637
}
3636
- zval_ptr_dtor ( & params [ 0 ]);
3637
- zval_ptr_dtor ( & params [ 1 ] );
3638
+
3639
+ zend_fcall_info_args_clear ( fci , 1 );
3638
3640
zval_ptr_dtor (& z_result );
3639
3641
3640
3642
return rc ;
0 commit comments