cvs: php4 /ext/standard basic_functions.c

From: Date: Fri, 09 Mar 2001 21:42:27 +0000
Subject: cvs: php4 /ext/standard basic_functions.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-4463@lists.php.net to get a copy of this message
andrei Fri Mar 9 13:42:27 2001 EDT Modified files: /php4/ext/standard basic_functions.c Log: @- Fixed argument checking for call_user_func* functions and allowed @ specifying array($obj, 'method') syntax for call_user_func_array. (Andrei) Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.312 php4/ext/standard/basic_functions.c:1.313 --- php4/ext/standard/basic_functions.c:1.312 Sat Mar 3 17:17:21 2001 +++ php4/ext/standard/basic_functions.c Fri Mar 9 13:42:26 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.312 2001/03/04 01:17:21 zeev Exp $ */ +/* $Id: basic_functions.c,v 1.313 2001/03/09 21:42:26 andrei Exp $ */ #include "php.h" #include "php_main.h" @@ -1597,12 +1597,17 @@ efree(params); RETURN_FALSE; } - SEPARATE_ZVAL(params[0]); + + if (Z_TYPE_PP(params[0]) != IS_STRING && Z_TYPE_PP(params[0]) != IS_ARRAY) { + SEPARATE_ZVAL(params[0]); + convert_to_string_ex(params[0]); + } + if (call_user_function_ex(CG(function_table), NULL, *params[0], &retval_ptr, arg_count-1, params+1, 1, NULL)==SUCCESS && retval_ptr) { COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr); } else { - php_error(E_WARNING,"Unable to call %s() - function does not exist", Z_STRVAL_PP(params[0])); + php_error(E_WARNING,"Unable to call %s() - function does not exist", Z_TYPE_PP(params[0]) == IS_STRING ? Z_STRVAL_PP(params[0]) : ""); } efree(params); } @@ -1625,9 +1630,14 @@ zend_get_parameters_ex(2, &func_name, &params) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_string_ex(func_name); + SEPARATE_ZVAL(params); convert_to_array_ex(params); + if (Z_TYPE_PP(func_name) != IS_STRING && Z_TYPE_PP(func_name) != IS_ARRAY) { + SEPARATE_ZVAL(func_name); + convert_to_string_ex(func_name); + } + params_ar = HASH_OF(*params); num_elems = zend_hash_num_elements(params_ar); @@ -1643,7 +1653,7 @@ && retval_ptr) { COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr); } else { - php_error(E_WARNING, "Unable to call %s() - function does not exist", Z_STRVAL_PP(func_name)); + php_error(E_WARNING, "Unable to call %s() - function does not exist", Z_TYPE_PP(func_name) == IS_STRING ? Z_STRVAL_PP(func_name) : ""); } efree(func_args);

« previous php.cvs (#4463) next »