mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
- MFH zend_info_call_*() stuff, fixes coverity issue #328, noticed by tony
This commit is contained in:
parent
3530b8a2c6
commit
9c5ea420ac
@ -2377,19 +2377,41 @@ ZEND_API int zend_fcall_info_init(zval *callable, zend_fcall_info *fci, zend_fca
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, int free_mem)
|
||||
{
|
||||
if (fci->params) {
|
||||
while (fci->param_count) {
|
||||
zval_ptr_dtor(fci->params[--fci->param_count]);
|
||||
}
|
||||
if (free_mem) {
|
||||
efree(fci->params);
|
||||
fci->params = NULL;
|
||||
}
|
||||
}
|
||||
fci->param_count = 0;
|
||||
}
|
||||
|
||||
ZEND_API void zend_fcall_info_args_save(zend_fcall_info *fci, int *param_count, zval ****params)
|
||||
{
|
||||
*param_count = fci->param_count;
|
||||
*params = fci->params;
|
||||
fci->param_count = 0;
|
||||
fci->params = NULL;
|
||||
}
|
||||
|
||||
ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, int param_count, zval ***params)
|
||||
{
|
||||
zend_fcall_info_args_clear(fci, 1);
|
||||
fci->param_count = param_count;
|
||||
fci->params = params;
|
||||
}
|
||||
|
||||
ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC)
|
||||
{
|
||||
HashPosition pos;
|
||||
zval **arg, ***params;
|
||||
|
||||
if (fci->params) {
|
||||
while (fci->param_count) {
|
||||
zval_ptr_dtor(fci->params[--fci->param_count]);
|
||||
}
|
||||
efree(fci->params);
|
||||
}
|
||||
fci->params = NULL;
|
||||
fci->param_count = 0;
|
||||
zend_fcall_info_args_clear(fci, !args);
|
||||
|
||||
if (!args) {
|
||||
return SUCCESS;
|
||||
@ -2403,7 +2425,6 @@ ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC)
|
||||
fci->params = params = (zval***)safe_emalloc(sizeof(zval**), fci->param_count, 0);
|
||||
|
||||
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos);
|
||||
|
||||
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(args), (void **) &arg, &pos) == SUCCESS) {
|
||||
*params++ = arg;
|
||||
(*arg)->refcount++;
|
||||
@ -2420,8 +2441,7 @@ ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *f
|
||||
|
||||
fci->retval_ptr_ptr = retval_ptr_ptr ? retval_ptr_ptr : &retval;
|
||||
if (args) {
|
||||
org_params = fci->params;
|
||||
org_count = fci->param_count;
|
||||
zend_fcall_info_args_save(fci, &org_count, &org_params);
|
||||
zend_fcall_info_args(fci, args TSRMLS_CC);
|
||||
}
|
||||
result = zend_call_function(fci, fcc TSRMLS_CC);
|
||||
@ -2430,9 +2450,7 @@ ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *f
|
||||
zval_ptr_dtor(&retval);
|
||||
}
|
||||
if (args) {
|
||||
zend_fcall_info_args(fci, NULL TSRMLS_CC);
|
||||
fci->params = org_params;
|
||||
fci->param_count = org_count;
|
||||
zend_fcall_info_args_restore(fci, org_count, org_params);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user