Created
July 6, 2014 12:48
-
-
Save laruence/bc1b3016f19e126a1465 to your computer and use it in GitHub Desktop.
callable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Zend/zend_API.c b/Zend/zend_API.c | |
index 6b469c2..5500f4f 100644 | |
--- a/Zend/zend_API.c | |
+++ b/Zend/zend_API.c | |
@@ -672,7 +672,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons | |
break; | |
} | |
- if (zend_fcall_info_init(arg, 0, fci, fcc, NULL, &is_callable_error TSRMLS_CC) == SUCCESS) { | |
+ if (zend_fcall_info_init(arg, 0, fci, fcc, &is_callable_error TSRMLS_CC) == SUCCESS) { | |
if (is_callable_error) { | |
*severity = E_STRICT; | |
zend_spprintf(error, 0, "to be a valid callback, %s", is_callable_error); | |
@@ -3112,14 +3112,11 @@ get_function_via_handler: | |
} | |
/* }}} */ | |
-ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */ | |
+ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint check_flags, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */ | |
{ | |
zend_bool ret; | |
zend_fcall_info_cache fcc_local; | |
- if (callable_name) { | |
- *callable_name = NULL; | |
- } | |
if (fcc == NULL) { | |
fcc = &fcc_local; | |
} | |
@@ -3145,20 +3142,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint | |
if (object) { | |
fcc->object = object; | |
fcc->calling_scope = zend_get_class_entry(object TSRMLS_CC); | |
- if (callable_name) { | |
- char *ptr; | |
- | |
- *callable_name = STR_ALLOC(fcc->calling_scope->name->len + Z_STRLEN_P(callable) + sizeof("::") - 1, 0); | |
- ptr = (*callable_name)->val; | |
- memcpy(ptr, fcc->calling_scope->name->val, fcc->calling_scope->name->len); | |
- ptr += fcc->calling_scope->name->len; | |
- memcpy(ptr, "::", sizeof("::") - 1); | |
- ptr += sizeof("::") - 1; | |
- memcpy(ptr, Z_STRVAL_P(callable), Z_STRLEN_P(callable) + 1); | |
- } | |
- } else if (callable_name) { | |
- *callable_name = STR_COPY(Z_STR_P(callable)); | |
- } | |
+ } | |
if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { | |
fcc->called_scope = fcc->calling_scope; | |
return 1; | |
@@ -3201,19 +3185,6 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint | |
ZVAL_DEREF(obj); | |
if (Z_TYPE_P(obj) == IS_STRING) { | |
- if (callable_name) { | |
- char *ptr; | |
- | |
- | |
- *callable_name = STR_ALLOC(Z_STRLEN_P(obj) + Z_STRLEN_P(method) + sizeof("::") - 1, 0); | |
- ptr = (*callable_name)->val; | |
- memcpy(ptr, Z_STRVAL_P(obj), Z_STRLEN_P(obj)); | |
- ptr += Z_STRLEN_P(obj); | |
- memcpy(ptr, "::", sizeof("::") - 1); | |
- ptr += sizeof("::") - 1; | |
- memcpy(ptr, Z_STRVAL_P(method), Z_STRLEN_P(method) + 1); | |
- } | |
- | |
if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { | |
return 1; | |
} | |
@@ -3232,18 +3203,6 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint | |
fcc->object = Z_OBJ_P(obj); | |
- if (callable_name) { | |
- char *ptr; | |
- | |
- *callable_name = STR_ALLOC(fcc->calling_scope->name->len + Z_STRLEN_P(method) + sizeof("::") - 1, 0); | |
- ptr = (*callable_name)->val; | |
- memcpy(ptr, fcc->calling_scope->name->val, fcc->calling_scope->name->len); | |
- ptr += fcc->calling_scope->name->len; | |
- memcpy(ptr, "::", sizeof("::") - 1); | |
- ptr += sizeof("::") - 1; | |
- memcpy(ptr, Z_STRVAL_P(method), Z_STRLEN_P(method) + 1); | |
- } | |
- | |
if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { | |
fcc->called_scope = fcc->calling_scope; | |
return 1; | |
@@ -3278,47 +3237,121 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint | |
} else { | |
if (error) zend_spprintf(error, 0, "array must have exactly two members"); | |
} | |
- if (callable_name) { | |
- *callable_name = STR_INIT("Array", sizeof("Array")-1, 0); | |
- } | |
} | |
return 0; | |
case IS_OBJECT: | |
if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &fcc->calling_scope, &fcc->function_handler, &fcc->object TSRMLS_CC) == SUCCESS) { | |
fcc->called_scope = fcc->calling_scope; | |
- if (callable_name) { | |
- zend_class_entry *ce = Z_OBJCE_P(callable); /* TBFixed: what if it's overloaded? */ | |
- | |
- *callable_name = STR_ALLOC(ce->name->len + sizeof("::__invoke") - 1, 0); | |
- memcpy((*callable_name)->val, ce->name->val, ce->name->len); | |
- memcpy((*callable_name)->val + ce->name->len, "::__invoke", sizeof("::__invoke")); | |
- } | |
return 1; | |
} | |
/* break missing intentionally */ | |
default: | |
- if (callable_name) { | |
- *callable_name = zval_get_string(callable); | |
- } | |
if (error) zend_spprintf(error, 0, "no array or string given"); | |
return 0; | |
} | |
} | |
/* }}} */ | |
-ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, zend_string **callable_name TSRMLS_DC) /* {{{ */ | |
+ZEND_API zend_string *zend_get_callable_name(zval *callable, zend_object *object TSRMLS_DC) /* {{{ */ { | |
+ zend_string *callable_name; | |
+ | |
+ switch (Z_TYPE_P(callable)) { | |
+ case IS_STRING: | |
+ if (object) { | |
+ char *ptr; | |
+ zend_class_entry *ce = object->ce; | |
+ | |
+ callable_name = STR_ALLOC(ce->name->len + Z_STRLEN_P(callable) + sizeof("::") - 1, 0); | |
+ ptr = callable_name->val; | |
+ memcpy(ptr, ce->name->val, ce->name->len); | |
+ ptr += ce->name->len; | |
+ memcpy(ptr, "::", sizeof("::") - 1); | |
+ ptr += sizeof("::") - 1; | |
+ memcpy(ptr, Z_STRVAL_P(callable), Z_STRLEN_P(callable) + 1); | |
+ } else { | |
+ callable_name = STR_COPY(Z_STR_P(callable)); | |
+ } | |
+ | |
+ case IS_ARRAY: | |
+ { | |
+ zval *method = NULL; | |
+ zval *obj = NULL; | |
+ | |
+ if (zend_hash_num_elements(Z_ARRVAL_P(callable)) == 2) { | |
+ obj = zend_hash_index_find(Z_ARRVAL_P(callable), 0); | |
+ method = zend_hash_index_find(Z_ARRVAL_P(callable), 1); | |
+ } | |
+ | |
+ do { | |
+ if (obj == NULL || method == NULL) { | |
+ break; | |
+ } | |
+ | |
+ ZVAL_DEREF(method); | |
+ if (Z_TYPE_P(method) != IS_STRING) { | |
+ break; | |
+ } | |
+ | |
+ ZVAL_DEREF(obj); | |
+ if (Z_TYPE_P(obj) == IS_STRING) { | |
+ char *ptr; | |
+ callable_name = STR_ALLOC(Z_STRLEN_P(obj) + Z_STRLEN_P(method) + sizeof("::") - 1, 0); | |
+ ptr = callable_name->val; | |
+ memcpy(ptr, Z_STRVAL_P(obj), Z_STRLEN_P(obj)); | |
+ ptr += Z_STRLEN_P(obj); | |
+ memcpy(ptr, "::", sizeof("::") - 1); | |
+ ptr += sizeof("::") - 1; | |
+ memcpy(ptr, Z_STRVAL_P(method), Z_STRLEN_P(method) + 1); | |
+ } else if (Z_TYPE_P(obj) == IS_OBJECT) { | |
+ char *ptr; | |
+ zend_class_entry *ce = Z_OBJCE_P(obj); | |
+ | |
+ callable_name = STR_ALLOC(ce->name->len + Z_STRLEN_P(method) + sizeof("::") - 1, 0); | |
+ ptr = callable_name->val; | |
+ memcpy(ptr, ce->name->val, ce->name->len); | |
+ ptr += ce->name->len; | |
+ memcpy(ptr, "::", sizeof("::") - 1); | |
+ ptr += sizeof("::") - 1; | |
+ memcpy(ptr, Z_STRVAL_P(method), Z_STRLEN_P(method) + 1); | |
+ } else { | |
+ break; | |
+ } | |
+ return callable_name; | |
+ } while (0); | |
+ callable_name = STR_INIT("Array", sizeof("Array")-1, 0); | |
+ } | |
+ break; | |
+ | |
+ case IS_OBJECT: | |
+ { | |
+ zend_class_entry *ce = Z_OBJCE_P(callable); | |
+ | |
+ callable_name = STR_ALLOC(ce->name->len + sizeof("::__invoke") - 1, 0); | |
+ memcpy(callable_name->val, ce->name->val, ce->name->len); | |
+ memcpy(callable_name->val + ce->name->len, "::__invoke", sizeof("::__invoke")); | |
+ } | |
+ break; | |
+ default: | |
+ callable_name = zval_get_string(callable); | |
+ } | |
+ | |
+ return callable_name; | |
+} | |
+/* }}} */ | |
+ | |
+ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags TSRMLS_DC) /* {{{ */ | |
{ | |
- return zend_is_callable_ex(callable, NULL, check_flags, callable_name, NULL, NULL TSRMLS_CC); | |
+ return zend_is_callable_ex(callable, NULL, check_flags, NULL, NULL TSRMLS_CC); | |
} | |
/* }}} */ | |
-ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_name TSRMLS_DC) /* {{{ */ | |
+ZEND_API zend_bool zend_make_callable(zval *callable TSRMLS_DC) /* {{{ */ | |
{ | |
zend_fcall_info_cache fcc; | |
- if (zend_is_callable_ex(callable, NULL, IS_CALLABLE_STRICT, callable_name, &fcc, NULL TSRMLS_CC)) { | |
+ if (zend_is_callable_ex(callable, NULL, IS_CALLABLE_STRICT, &fcc, NULL TSRMLS_CC)) { | |
if (Z_TYPE_P(callable) == IS_STRING && fcc.calling_scope) { | |
zval_dtor(callable); | |
array_init(callable); | |
@@ -3341,9 +3374,9 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam | |
} | |
/* }}} */ | |
-ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error TSRMLS_DC) /* {{{ */ | |
+ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */ | |
{ | |
- if (!zend_is_callable_ex(callable, NULL, check_flags, callable_name, fcc, error TSRMLS_CC)) { | |
+ if (!zend_is_callable_ex(callable, NULL, check_flags, fcc, error TSRMLS_CC)) { | |
return FAILURE; | |
} | |
diff --git a/Zend/zend_API.h b/Zend/zend_API.h | |
index eafdf64..5bf3945 100644 | |
--- a/Zend/zend_API.h | |
+++ b/Zend/zend_API.h | |
@@ -295,9 +295,10 @@ ZEND_API void zend_wrong_param_count(TSRMLS_D); | |
#define IS_CALLABLE_STRICT (IS_CALLABLE_CHECK_IS_STATIC) | |
-ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error TSRMLS_DC); | |
-ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, zend_string **callable_name TSRMLS_DC); | |
-ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_name TSRMLS_DC); | |
+ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint check_flags, zend_fcall_info_cache *fcc, char **error TSRMLS_DC); | |
+ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags TSRMLS_DC); | |
+ZEND_API zend_bool zend_make_callable(zval *callable TSRMLS_DC); | |
+ZEND_API zend_string *zend_get_callable_name(zval *callable, zend_object *object); | |
ZEND_API const char *zend_get_module_version(const char *module_name); | |
ZEND_API int zend_get_module_started(const char *module_name); | |
ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment TSRMLS_DC); | |
@@ -471,7 +472,7 @@ ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache; | |
* The callable_name argument may be NULL. | |
* Set check_flags to IS_CALLABLE_STRICT for every new usage! | |
*/ | |
-ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error TSRMLS_DC); | |
+ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, char **error TSRMLS_DC); | |
/** Clear arguments connected with zend_fcall_info *fci | |
* If free_mem is not zero then the params array gets free'd as well | |
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c | |
index df81c5d..aa2f4b4 100644 | |
--- a/Zend/zend_builtin_functions.c | |
+++ b/Zend/zend_builtin_functions.c | |
@@ -1508,13 +1508,13 @@ ZEND_FUNCTION(set_error_handler) | |
} | |
if (Z_TYPE_P(error_handler) != IS_NULL) { /* NULL == unset */ | |
- if (!zend_is_callable(error_handler, 0, &error_handler_name TSRMLS_CC)) { | |
+ if (!zend_is_callable(error_handler, 0 TSRMLS_CC)) { | |
+ error_handler_name = zend_get_callable_name(error_handler, NULL TSRMLS_CC); | |
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback", | |
- get_active_function_name(TSRMLS_C), error_handler_name?error_handler_name->val:"unknown"); | |
+ get_active_function_name(TSRMLS_C), error_handler_name->val); | |
STR_RELEASE(error_handler_name); | |
return; | |
} | |
- STR_RELEASE(error_handler_name); | |
} | |
if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) { | |
@@ -1574,13 +1574,13 @@ ZEND_FUNCTION(set_exception_handler) | |
} | |
if (Z_TYPE_P(exception_handler) != IS_NULL) { /* NULL == unset */ | |
- if (!zend_is_callable(exception_handler, 0, &exception_handler_name TSRMLS_CC)) { | |
+ if (!zend_is_callable(exception_handler, 0 TSRMLS_CC)) { | |
+ exception_handler_name = zend_get_callable_name(exception_handler, NULL TSRMLS_CC); | |
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback", | |
- get_active_function_name(TSRMLS_C), exception_handler_name?exception_handler_name->val:"unknown"); | |
+ get_active_function_name(TSRMLS_C), exception_handler_name->val); | |
STR_RELEASE(exception_handler_name); | |
return; | |
} | |
- STR_RELEASE(exception_handler_name); | |
} | |
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) { | |
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c | |
index 5318bbe..27c5961 100644 | |
--- a/Zend/zend_execute.c | |
+++ b/Zend/zend_execute.c | |
@@ -595,7 +595,7 @@ static void zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zval *arg | |
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be of the type array", "", zend_zval_type_name(arg), "", arg TSRMLS_CC); | |
} | |
} else if (cur_arg_info->type_hint == IS_CALLABLE) { | |
- if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL TSRMLS_CC) && (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null)) { | |
+ if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT TSRMLS_CC) && (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null)) { | |
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", zend_zval_type_name(arg), "", arg TSRMLS_CC); | |
} | |
#if ZEND_DEBUG | |
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c | |
index 2ba5829..4104605 100644 | |
--- a/Zend/zend_execute_API.c | |
+++ b/Zend/zend_execute_API.c | |
@@ -714,13 +714,12 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS | |
fci_cache = &fci_cache_local; | |
} | |
- if (!zend_is_callable_ex(&fci->function_name, fci->object, IS_CALLABLE_CHECK_SILENT, &callable_name, fci_cache, &error TSRMLS_CC)) { | |
+ if (!zend_is_callable_ex(&fci->function_name, fci->object, IS_CALLABLE_CHECK_SILENT, fci_cache, &error TSRMLS_CC)) { | |
if (error) { | |
+ callable_name = zend_get_callable_name(&fci->function_name, fci->object TSRMLS_CC); | |
zend_error(E_WARNING, "Invalid callback %s, %s", callable_name->val, error); | |
- efree(error); | |
- } | |
- if (callable_name) { | |
STR_RELEASE(callable_name); | |
+ efree(error); | |
} | |
return FAILURE; | |
} else if (error) { | |
@@ -731,7 +730,6 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS | |
zend_error(E_STRICT, "%s", error); | |
efree(error); | |
} | |
- STR_RELEASE(callable_name); | |
} | |
func = fci_cache->function_handler; | |
diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c | |
index 93a3861..99a65b2 100644 | |
--- a/ext/dom/xpath.c | |
+++ b/ext/dom/xpath.c | |
@@ -194,12 +194,16 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, | |
fci.retval = &retval; | |
fci.no_separation = 0; | |
- if (!zend_make_callable(&fci.function_name, &callable TSRMLS_CC)) { | |
+ if (!zend_make_callable(&fci.function_name TSRMLS_CC)) { | |
+ callable = zend_get_callable_name(&fci.function_name, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", callable->val); | |
+ STR_RELEASE(callable); | |
} else if (intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) { | |
+ callable = zend_get_callable_name(&fci.function_name, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not allowed to call handler '%s()'.", callable->val); | |
/* Push an empty string, so that we at least have an xslt result... */ | |
valuePush(ctxt, xmlXPathNewString((xmlChar *)"")); | |
+ STR_RELEASE(callable); | |
} else { | |
result = zend_call_function(&fci, NULL TSRMLS_CC); | |
if (result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) { | |
@@ -228,7 +232,6 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, | |
zval_ptr_dtor(&retval); | |
} | |
} | |
- STR_RELEASE(callable); | |
zval_dtor(&fci.function_name); | |
if (fci.param_count > 0) { | |
for (i = 0; i < nargs - 1; i++) { | |
diff --git a/ext/filter/callback_filter.c b/ext/filter/callback_filter.c | |
index 49410db..372e955 100644 | |
--- a/ext/filter/callback_filter.c | |
+++ b/ext/filter/callback_filter.c | |
@@ -26,7 +26,7 @@ void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL) | |
zval *args; | |
int status; | |
- if (!option_array || !zend_is_callable(option_array, IS_CALLABLE_CHECK_NO_ACCESS, NULL TSRMLS_CC)) { | |
+ if (!option_array || !zend_is_callable(option_array, IS_CALLABLE_CHECK_NO_ACCESS TSRMLS_CC)) { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "First argument is expected to be a valid callback"); | |
zval_ptr_dtor(value); | |
ZVAL_NULL(value); | |
diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c | |
index 0064497..d8d9eb4 100644 | |
--- a/ext/intl/converter/converter.c | |
+++ b/ext/intl/converter/converter.c | |
@@ -543,7 +543,7 @@ static void php_converter_resolve_callback(zval *zobj, | |
Z_ADDREF_P(zobj); | |
add_index_zval(&caller, 0, zobj); | |
add_index_string(&caller, 1, callback_name); | |
- if (zend_fcall_info_init(&caller, 0, finfo, fcache, NULL, &errstr TSRMLS_CC) == FAILURE) { | |
+ if (zend_fcall_info_init(&caller, 0, finfo, fcache, &errstr TSRMLS_CC) == FAILURE) { | |
php_converter_throw_failure(objval, U_INTERNAL_PROGRAM_ERROR TSRMLS_CC, "Error setting converter callback: %s", errstr); | |
} | |
zval_dtor(&caller); | |
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c | |
index 8f52f1f..e40bf98 100644 | |
--- a/ext/ldap/ldap.c | |
+++ b/ext/ldap/ldap.c | |
@@ -2461,12 +2461,12 @@ PHP_FUNCTION(ldap_set_rebind_proc) | |
} | |
/* callable? */ | |
- if (!zend_is_callable(callback, 0, &callback_name TSRMLS_CC)) { | |
+ if (!zend_is_callable(callback, 0 TSRMLS_CC)) { | |
+ callback_name = zend_get_callable_name(callback, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Two arguments expected for '%s' to be a valid callback", callback_name->val); | |
STR_RELEASE(callback_name); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(callback_name); | |
/* register rebind procedure */ | |
if (Z_ISUNDEF(ld->rebindproc)) { | |
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c | |
index 448e34b..75bb55e 100644 | |
--- a/ext/pcntl/pcntl.c | |
+++ b/ext/pcntl/pcntl.c | |
@@ -876,13 +876,13 @@ PHP_FUNCTION(pcntl_signal) | |
RETURN_TRUE; | |
} | |
- if (!zend_is_callable(handle, 0, &func_name TSRMLS_CC)) { | |
+ if (!zend_is_callable(handle, 0 TSRMLS_CC)) { | |
+ func_name = zend_get_callable_name(handle, NULL TSRMLS_CC); | |
PCNTL_G(last_error) = EINVAL; | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not a callable function name error", func_name->val); | |
STR_RELEASE(func_name); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(func_name); | |
/* Add the function name to our signal table */ | |
if (zend_hash_index_update(&PCNTL_G(php_signal_table), signo, handle)) { | |
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c | |
index e4b7601..a48d085 100644 | |
--- a/ext/pcre/php_pcre.c | |
+++ b/ext/pcre/php_pcre.c | |
@@ -1446,13 +1446,13 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl | |
convert_to_string_ex(replace); | |
} | |
if (is_callable_replace) { | |
- if (!zend_is_callable(replace, 0, &callback_name TSRMLS_CC)) { | |
+ if (!zend_is_callable(replace, 0 TSRMLS_CC)) { | |
+ callback_name = zend_get_callable_name(replace, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires argument 2, '%s', to be a valid callback", callback_name->val); | |
STR_RELEASE(callback_name); | |
ZVAL_DUP(return_value, subject); | |
return; | |
} | |
- STR_RELEASE(callback_name); | |
} | |
if (ZEND_NUM_ARGS() > 3) { | |
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c | |
index bb24d30..531c55d 100644 | |
--- a/ext/pdo/pdo_stmt.c | |
+++ b/ext/pdo/pdo_stmt.c | |
@@ -768,7 +768,7 @@ static int make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info * | |
{ | |
char *is_callable_error = NULL; | |
- if (zend_fcall_info_init(callable, 0, fci, fcc, NULL, &is_callable_error TSRMLS_CC) == FAILURE) { | |
+ if (zend_fcall_info_init(callable, 0, fci, fcc, &is_callable_error TSRMLS_CC) == FAILURE) { | |
if (is_callable_error) { | |
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", is_callable_error TSRMLS_CC); | |
efree(is_callable_error); | |
@@ -777,10 +777,6 @@ static int make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info * | |
} | |
return 0; | |
} | |
- if (is_callable_error) { | |
- /* Possible E_STRICT error message */ | |
- efree(is_callable_error); | |
- } | |
fci->param_count = num_args; /* probably less */ | |
fci->params = safe_emalloc(sizeof(zval), num_args, 0); | |
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c | |
index 9b47af5..ff2b679 100644 | |
--- a/ext/pdo_sqlite/sqlite_driver.c | |
+++ b/ext/pdo_sqlite/sqlite_driver.c | |
@@ -536,12 +536,12 @@ static PHP_METHOD(SQLite, sqliteCreateFunction) | |
dbh = Z_PDO_DBH_P(getThis()); | |
PDO_CONSTRUCT_CHECK; | |
- if (!zend_is_callable(callback, 0, &cbname TSRMLS_CC)) { | |
+ if (!zend_is_callable(callback, 0 TSRMLS_CC)) { | |
+ cbname = zend_get_callable_name(callback, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname->val); | |
STR_RELEASE(cbname); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(cbname); | |
H = (pdo_sqlite_db_handle *)dbh->driver_data; | |
@@ -606,18 +606,18 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate) | |
dbh = Z_PDO_DBH_P(getThis()); | |
PDO_CONSTRUCT_CHECK; | |
- if (!zend_is_callable(step_callback, 0, &cbname TSRMLS_CC)) { | |
+ if (!zend_is_callable(step_callback, 0 TSRMLS_CC)) { | |
+ cbname = zend_get_callable_name(step_callback, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname->val); | |
STR_RELEASE(cbname); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(cbname); | |
- if (!zend_is_callable(fini_callback, 0, &cbname TSRMLS_CC)) { | |
+ if (!zend_is_callable(fini_callback, 0 TSRMLS_CC)) { | |
+ cbname = zend_get_callable_name(fini_callback, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname->val); | |
STR_RELEASE(cbname); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(cbname); | |
H = (pdo_sqlite_db_handle *)dbh->driver_data; | |
@@ -666,12 +666,12 @@ static PHP_METHOD(SQLite, sqliteCreateCollation) | |
dbh = Z_PDO_DBH_P(getThis()); | |
PDO_CONSTRUCT_CHECK; | |
- if (!zend_is_callable(callback, 0, &cbname TSRMLS_CC)) { | |
+ if (!zend_is_callable(callback, 0 TSRMLS_CC)) { | |
+ cbname = zend_get_callable_name(callback, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname->val); | |
STR_RELEASE(cbname); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(cbname); | |
H = (pdo_sqlite_db_handle *)dbh->driver_data; | |
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c | |
index 048362d..14b35e6 100644 | |
--- a/ext/phar/phar_object.c | |
+++ b/ext/phar/phar_object.c | |
@@ -678,7 +678,7 @@ PHP_METHOD(Phar, webPhar) | |
ZVAL_STRINGL(¶ms, entry, entry_len); | |
- if (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL, NULL TSRMLS_CC)) { | |
+ if (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL TSRMLS_CC)) { | |
zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar error: invalid rewrite callback"); | |
if (free_pathinfo) { | |
diff --git a/ext/phar/util.c b/ext/phar/util.c | |
index 4d260a4..515065c 100644 | |
--- a/ext/phar/util.c | |
+++ b/ext/phar/util.c | |
@@ -1414,7 +1414,7 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, | |
return FAILURE; | |
} | |
- if (FAILURE == zend_fcall_info_init(&openssl, 0, &fci, &fcc, NULL, NULL TSRMLS_CC)) { | |
+ if (FAILURE == zend_fcall_info_init(&openssl, 0, &fci, &fcc, NULL TSRMLS_CC)) { | |
zval_dtor(&zp[0]); | |
zval_dtor(&zp[1]); | |
zval_dtor(&zp[2]); | |
diff --git a/ext/readline/readline.c b/ext/readline/readline.c | |
index 22b727b..aeb2c13 100644 | |
--- a/ext/readline/readline.c | |
+++ b/ext/readline/readline.c | |
@@ -513,18 +513,18 @@ static char **_readline_completion_cb(const char *text, int start, int end) | |
PHP_FUNCTION(readline_completion_function) | |
{ | |
zval *arg = NULL; | |
- zend_string *name = NULL; | |
+ zend_string *name; | |
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg)) { | |
RETURN_FALSE; | |
} | |
- if (!zend_is_callable(arg, 0, &name TSRMLS_CC)) { | |
+ if (!zend_is_callable(arg, 0 TSRMLS_CC)) { | |
+ name = zend_get_callable_name(arg, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not callable", name->val); | |
STR_RELEASE(name); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(name); | |
zval_dtor(&_readline_completion); | |
ZVAL_DUP(&_readline_completion, arg); | |
@@ -561,7 +561,7 @@ static void php_rl_callback_handler(char *the_line) | |
PHP_FUNCTION(readline_callback_handler_install) | |
{ | |
zval *callback; | |
- zend_string *name = NULL; | |
+ zend_string *name; | |
char *prompt; | |
int prompt_len; | |
@@ -569,12 +569,12 @@ PHP_FUNCTION(readline_callback_handler_install) | |
return; | |
} | |
- if (!zend_is_callable(callback, 0, &name TSRMLS_CC)) { | |
+ if (!zend_is_callable(callback, 0 TSRMLS_CC)) { | |
+ name = zend_get_callable_name(callback, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not callable", name->val); | |
STR_RELEASE(name); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(name); | |
if (Z_TYPE(_prepped_callback) != IS_UNDEF) { | |
rl_callback_handler_remove(); | |
diff --git a/ext/session/session.c b/ext/session/session.c | |
index 529e6ee..0cb3237 100644 | |
--- a/ext/session/session.c | |
+++ b/ext/session/session.c | |
@@ -1761,7 +1761,6 @@ static PHP_FUNCTION(session_set_save_handler) | |
{ | |
zval *args = NULL; | |
int i, num_args, argc = ZEND_NUM_ARGS(); | |
- zend_string *name; | |
zend_string *ini_name; | |
if (PS(session_status) != php_session_none) { | |
@@ -1866,12 +1865,10 @@ static PHP_FUNCTION(session_set_save_handler) | |
/* at this point argc can only be 6 or 7 */ | |
for (i = 0; i < argc; i++) { | |
- if (!zend_is_callable(&args[i], 0, &name TSRMLS_CC)) { | |
+ if (!zend_is_callable(&args[i], 0 TSRMLS_CC)) { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument %d is not a valid callback", i+1); | |
- STR_RELEASE(name); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(name); | |
} | |
if (PS(mod) && PS(mod) != &ps_mod_user) { | |
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c | |
index 5ec20cd..b7a91e0 100644 | |
--- a/ext/spl/php_spl.c | |
+++ b/ext/spl/php_spl.c | |
@@ -498,7 +498,7 @@ PHP_FUNCTION(spl_autoload_register) | |
} | |
if (ZEND_NUM_ARGS()) { | |
- if (!zend_is_callable_ex(zcallable, NULL, IS_CALLABLE_STRICT, &func_name, &fcc, &error TSRMLS_CC)) { | |
+ if (!zend_is_callable_ex(zcallable, NULL, IS_CALLABLE_STRICT, &fcc, &error TSRMLS_CC)) { | |
alfi.ce = fcc.calling_scope; | |
alfi.func_ptr = fcc.function_handler; | |
obj_ptr = fcc.object; | |
@@ -510,7 +510,6 @@ PHP_FUNCTION(spl_autoload_register) | |
if (error) { | |
efree(error); | |
} | |
- STR_RELEASE(func_name); | |
RETURN_FALSE; | |
} else if (do_throw) { | |
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Passed array does not specify %s %smethod (%s)", alfi.func_ptr ? "a callable" : "an existing", !obj_ptr ? "static " : "", error); | |
@@ -518,16 +517,16 @@ PHP_FUNCTION(spl_autoload_register) | |
if (error) { | |
efree(error); | |
} | |
- STR_RELEASE(func_name); | |
RETURN_FALSE; | |
} else if (Z_TYPE_P(zcallable) == IS_STRING) { | |
if (do_throw) { | |
+ func_name = zend_get_callable_name(zcallable, NULL TSRMLS_CC); | |
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Function '%s' not %s (%s)", func_name->val, alfi.func_ptr ? "callable" : "found", error); | |
+ STR_RELEASE(func_name); | |
} | |
if (error) { | |
efree(error); | |
} | |
- STR_RELEASE(func_name); | |
RETURN_FALSE; | |
} else { | |
if (do_throw) { | |
@@ -536,7 +535,6 @@ PHP_FUNCTION(spl_autoload_register) | |
if (error) { | |
efree(error); | |
} | |
- STR_RELEASE(func_name); | |
RETURN_FALSE; | |
} | |
} else if (fcc.function_handler->type == ZEND_INTERNAL_FUNCTION && | |
@@ -547,7 +545,6 @@ PHP_FUNCTION(spl_autoload_register) | |
if (error) { | |
efree(error); | |
} | |
- STR_RELEASE(func_name); | |
RETURN_FALSE; | |
} | |
alfi.ce = fcc.calling_scope; | |
@@ -557,6 +554,7 @@ PHP_FUNCTION(spl_autoload_register) | |
efree(error); | |
} | |
+ func_name = zend_get_callable_name(zcallable, NULL TSRMLS_CC); | |
if (Z_TYPE_P(zcallable) == IS_OBJECT) { | |
ZVAL_COPY(&alfi.closure, zcallable); | |
@@ -653,14 +651,11 @@ PHP_FUNCTION(spl_autoload_unregister) | |
return; | |
} | |
- if (!zend_is_callable_ex(zcallable, NULL, IS_CALLABLE_CHECK_SYNTAX_ONLY, &func_name, &fcc, &error TSRMLS_CC)) { | |
+ if (!zend_is_callable_ex(zcallable, NULL, IS_CALLABLE_CHECK_SYNTAX_ONLY, &fcc, &error TSRMLS_CC)) { | |
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Unable to unregister invalid function (%s)", error); | |
if (error) { | |
efree(error); | |
} | |
- if (func_name) { | |
- STR_RELEASE(func_name); | |
- } | |
RETURN_FALSE; | |
} | |
obj_ptr = fcc.object; | |
@@ -668,6 +663,7 @@ PHP_FUNCTION(spl_autoload_unregister) | |
efree(error); | |
} | |
+ func_name = zend_get_callable_name(zcallable, NULL TSRMLS_CC); | |
if (Z_TYPE_P(zcallable) == IS_OBJECT) { | |
lc_name = STR_ALLOC(func_name->len + sizeof(zend_uint), 0); | |
zend_str_tolower_copy(lc_name->val, func_name->val, func_name->len); | |
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c | |
index 80f2a62..58626a4 100644 | |
--- a/ext/spl/spl_iterators.c | |
+++ b/ext/spl/spl_iterators.c | |
@@ -1308,8 +1308,7 @@ int spl_dual_it_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS) | |
intern = Z_SPLDUAL_IT_P(getThis()); | |
- ZVAL_STRING(&func, method, 0); | |
- if (!zend_is_callable(&func, 0, &method TSRMLS_CC)) { | |
+ if (!zend_is_callable(&func, 0 TSRMLS_CC)) { | |
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Method %s::%s() does not exist", intern->inner.ce->name, method); | |
return FAILURE; | |
} | |
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c | |
index c31ef3e..4c73916 100644 | |
--- a/ext/sqlite3/sqlite3.c | |
+++ b/ext/sqlite3/sqlite3.c | |
@@ -902,12 +902,12 @@ PHP_METHOD(sqlite3, createFunction) | |
RETURN_FALSE; | |
} | |
- if (!zend_is_callable(callback_func, 0, &callback_name TSRMLS_CC)) { | |
+ if (!zend_is_callable(callback_func, 0 TSRMLS_CC)) { | |
+ callback_name = zend_get_callable_name(callback_func, NULL TSRMLS_CC); | |
php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name->val); | |
STR_RELEASE(callback_name); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(callback_name); | |
func = (php_sqlite3_func *)ecalloc(1, sizeof(*func)); | |
@@ -952,19 +952,19 @@ PHP_METHOD(sqlite3, createAggregate) | |
RETURN_FALSE; | |
} | |
- if (!zend_is_callable(step_callback, 0, &callback_name TSRMLS_CC)) { | |
+ if (!zend_is_callable(step_callback, 0 TSRMLS_CC)) { | |
+ callback_name = zend_get_callable_name(step_callback, NULL TSRMLS_CC); | |
php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name->val); | |
STR_RELEASE(callback_name); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(callback_name); | |
- if (!zend_is_callable(fini_callback, 0, &callback_name TSRMLS_CC)) { | |
+ if (!zend_is_callable(fini_callback, 0 TSRMLS_CC)) { | |
+ callback_name = zend_get_callable_name(fini_callback, NULL TSRMLS_CC); | |
php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name->val); | |
STR_RELEASE(callback_name); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(callback_name); | |
func = (php_sqlite3_func *)ecalloc(1, sizeof(*func)); | |
@@ -1009,12 +1009,12 @@ PHP_METHOD(sqlite3, createCollation) | |
RETURN_FALSE; | |
} | |
- if (!zend_is_callable(callback_func, 0, &callback_name TSRMLS_CC)) { | |
+ if (!zend_is_callable(callback_func, 0 TSRMLS_CC)) { | |
+ callback_name = zend_get_callable_name(callback_func, NULL TSRMLS_CC); | |
php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name->val); | |
STR_RELEASE(callback_name); | |
RETURN_FALSE; | |
} | |
- STR_RELEASE(callback_name); | |
collation = (php_sqlite3_collation *)ecalloc(1, sizeof(*collation)); | |
if (sqlite3_create_collation(db_obj->db, collation_name, SQLITE_UTF8, collation, php_sqlite3_callback_compare) == SQLITE_OK) { | |
diff --git a/ext/standard/array.c b/ext/standard/array.c | |
index e1113a8..db3a918 100644 | |
--- a/ext/standard/array.c | |
+++ b/ext/standard/array.c | |
@@ -567,7 +567,7 @@ static int php_array_user_compare(const void *a, const void *b TSRMLS_DC) /* {{{ | |
/* check if comparison function is valid */ | |
#define PHP_ARRAY_CMP_FUNC_CHECK(func_name) \ | |
- if (!zend_is_callable(*func_name, 0, NULL TSRMLS_CC)) { \ | |
+ if (!zend_is_callable(*func_name, 0 TSRMLS_CC)) { \ | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid comparison function"); \ | |
BG(user_compare_fci) = old_user_compare_fci; \ | |
BG(user_compare_fci_cache) = old_user_compare_fci_cache; \ | |
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c | |
index c8b3f96..ba01cbb 100644 | |
--- a/ext/standard/basic_functions.c | |
+++ b/ext/standard/basic_functions.c | |
@@ -4834,15 +4834,11 @@ static int user_shutdown_function_call(zval *zv TSRMLS_DC) /* {{{ */ | |
zval retval; | |
zend_string *function_name; | |
- if (!zend_is_callable(&shutdown_function_entry->arguments[0], 0, &function_name TSRMLS_CC)) { | |
+ if (!zend_is_callable(&shutdown_function_entry->arguments[0], 0 TSRMLS_CC)) { | |
+ function_name = zend_get_callable_name(&shutdown_function_entry->arguments[0], NULL TSRMLS_CC); | |
php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", function_name->val); | |
- if (function_name) { | |
- STR_RELEASE(function_name); | |
- } | |
- return 0; | |
- } | |
- if (function_name) { | |
STR_RELEASE(function_name); | |
+ return 0; | |
} | |
if (call_user_function(EG(function_table), NULL, | |
@@ -4965,7 +4961,7 @@ void php_free_shutdown_functions(TSRMLS_D) /* {{{ */ | |
PHP_FUNCTION(register_shutdown_function) | |
{ | |
php_shutdown_function_entry shutdown_function_entry; | |
- zend_string *callback_name = NULL; | |
+ zend_string *callback_name; | |
int i; | |
shutdown_function_entry.arg_count = ZEND_NUM_ARGS(); | |
@@ -4982,9 +4978,11 @@ PHP_FUNCTION(register_shutdown_function) | |
} | |
/* Prevent entering of anything but valid callback (syntax check only!) */ | |
- if (!zend_is_callable(&shutdown_function_entry.arguments[0], 0, &callback_name TSRMLS_CC)) { | |
+ if (!zend_is_callable(&shutdown_function_entry.arguments[0], 0 TSRMLS_CC)) { | |
+ callback_name = zend_get_callable_name(&shutdown_function_entry.arguments[0], NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid shutdown callback '%s' passed", callback_name->val); | |
efree(shutdown_function_entry.arguments); | |
+ STR_RELEASE(callback_name); | |
RETVAL_FALSE; | |
} else { | |
if (!BG(user_shutdown_function_names)) { | |
@@ -4997,9 +4995,6 @@ PHP_FUNCTION(register_shutdown_function) | |
} | |
zend_hash_next_index_insert_mem(BG(user_shutdown_function_names), &shutdown_function_entry, sizeof(php_shutdown_function_entry)); | |
} | |
- if (callback_name) { | |
- STR_RELEASE(callback_name); | |
- } | |
} | |
/* }}} */ | |
@@ -5592,14 +5587,13 @@ PHP_FUNCTION(register_tick_function) | |
RETURN_FALSE; | |
} | |
- if (!zend_is_callable(&tick_fe.arguments[0], 0, &function_name TSRMLS_CC)) { | |
+ if (!zend_is_callable(&tick_fe.arguments[0], 0 TSRMLS_CC)) { | |
+ function_name = zend_get_callable_name(&tick_fe.arguments[0], NULL TSRMLS_CC); | |
efree(tick_fe.arguments); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid tick callback '%s' passed", function_name->val); | |
STR_RELEASE(function_name); | |
RETURN_FALSE; | |
- } else if (function_name) { | |
- STR_RELEASE(function_name); | |
- } | |
+ } | |
if (Z_TYPE(tick_fe.arguments[0]) != IS_ARRAY && Z_TYPE(tick_fe.arguments[0]) != IS_OBJECT) { | |
convert_to_string_ex(&tick_fe.arguments[0]); | |
diff --git a/ext/standard/type.c b/ext/standard/type.c | |
index 72f1660..949b3dc 100644 | |
--- a/ext/standard/type.c | |
+++ b/ext/standard/type.c | |
@@ -388,7 +388,8 @@ PHP_FUNCTION(is_callable) | |
check_flags |= IS_CALLABLE_CHECK_SYNTAX_ONLY; | |
} | |
if (ZEND_NUM_ARGS() > 2) { | |
- retval = zend_is_callable_ex(var, NULL, check_flags, &name, NULL, &error TSRMLS_CC); | |
+ retval = zend_is_callable_ex(var, NULL, check_flags, NULL, &error TSRMLS_CC); | |
+ name = zend_get_callable_name(var, NULL TSRMLS_CC); | |
zval_dtor(callable_name); | |
//??? is it necessary to be consistent with old PHP ("\0" support) | |
if (UNEXPECTED(name->len) != strlen(name->val)) { | |
@@ -398,7 +399,7 @@ PHP_FUNCTION(is_callable) | |
ZVAL_STR(callable_name, name); | |
} | |
} else { | |
- retval = zend_is_callable_ex(var, NULL, check_flags, NULL, NULL, &error TSRMLS_CC); | |
+ retval = zend_is_callable_ex(var, NULL, check_flags, NULL, &error TSRMLS_CC); | |
} | |
if (error) { | |
/* ignore errors */ | |
diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c | |
index e4be0f0..f9f1dd6 100644 | |
--- a/ext/xmlrpc/xmlrpc-epi-php.c | |
+++ b/ext/xmlrpc/xmlrpc-epi-php.c | |
@@ -910,7 +910,7 @@ static void php_xmlrpc_introspection_callback(XMLRPC_SERVER server, void* data) | |
ZVAL_COPY_VALUE(&callback_params[0], &pData->caller_params); | |
ZEND_HASH_FOREACH_VAL(Z_ARRVAL(pData->server->introspection_map), php_function) { | |
- if (zend_is_callable(php_function, 0, &php_function_name TSRMLS_CC)) { | |
+ if (zend_is_callable(php_function, 0 TSRMLS_CC)) { | |
/* php func prototype: function string user_func($user_params) */ | |
if (call_user_function(CG(function_table), NULL, php_function, &retval, 1, callback_params TSRMLS_CC) == SUCCESS) { | |
XMLRPC_VALUE xData; | |
@@ -923,10 +923,13 @@ static void php_xmlrpc_introspection_callback(XMLRPC_SERVER server, void* data) | |
if (xData) { | |
if (!XMLRPC_ServerAddIntrospectionData(server, xData)) { | |
+ php_function_name = zend_get_callable_name(php_function, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add introspection data returned from %s(), improper element structure", php_function_name->val); | |
+ STR_RELEASE(php_function_name); | |
} | |
XMLRPC_CleanupValue(xData); | |
} else { | |
+ php_function_name = zend_get_callable_name(php_function, NULL TSRMLS_CC); | |
/* could not create description */ | |
if (err.xml_elem_error.parser_code) { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "xml parse error: [line %ld, column %ld, message: %s] Unable to add introspection data returned from %s()", | |
@@ -934,16 +937,20 @@ static void php_xmlrpc_introspection_callback(XMLRPC_SERVER server, void* data) | |
} else { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add introspection data returned from %s()", php_function_name->val); | |
} | |
+ STR_RELEASE(php_function_name); | |
} | |
zval_ptr_dtor(&retval); | |
} else { | |
+ php_function_name = zend_get_callable_name(php_function, NULL TSRMLS_CC); | |
/* user func failed */ | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error calling user introspection callback: %s()", php_function_name->val); | |
+ STR_RELEASE(php_function_name); | |
} | |
} else { | |
+ php_function_name = zend_get_callable_name(php_function, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid callback '%s' passed", php_function_name->val); | |
+ STR_RELEASE(php_function_name); | |
} | |
- STR_RELEASE(php_function_name); | |
} ZEND_HASH_FOREACH_END(); | |
/* so we don't call the same callbacks ever again */ | |
diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c | |
index 8c97ee6..a0fb0be 100644 | |
--- a/ext/xsl/xsltprocessor.c | |
+++ b/ext/xsl/xsltprocessor.c | |
@@ -316,13 +316,17 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t | |
fci.retval = &retval; | |
fci.no_separation = 0; | |
/*fci.function_handler_cache = &function_ptr;*/ | |
- if (!zend_make_callable(&handler, &callable TSRMLS_CC)) { | |
+ if (!zend_make_callable(&handler TSRMLS_CC)) { | |
+ callable = zend_get_callable_name(&handler, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", callable->val); | |
valuePush(ctxt, xmlXPathNewString("")); | |
+ STR_RELEASE(callable); | |
} else if ( intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) { | |
+ callable = zend_get_callable_name(&handler, NULL TSRMLS_CC); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not allowed to call handler '%s()'", callable->val); | |
/* Push an empty string, so that we at least have an xslt result... */ | |
valuePush(ctxt, xmlXPathNewString("")); | |
+ STR_RELEASE(callable); | |
} else { | |
result = zend_call_function(&fci, NULL TSRMLS_CC); | |
if (result == FAILURE) { | |
@@ -357,7 +361,6 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t | |
zval_ptr_dtor(&retval); | |
} | |
} | |
- STR_RELEASE(callable); | |
zval_ptr_dtor(&handler); | |
if (fci.param_count > 0) { | |
for (i = 0; i < nargs - 1; i++) { | |
diff --git a/main/SAPI.c b/main/SAPI.c | |
index e587f7a..33700ce 100644 | |
--- a/main/SAPI.c | |
+++ b/main/SAPI.c | |
@@ -134,7 +134,7 @@ PHP_FUNCTION(header_register_callback) | |
return; | |
} | |
- if (!zend_is_callable(callback_func, 0, NULL TSRMLS_CC)) { | |
+ if (!zend_is_callable(callback_func, 0 TSRMLS_CC)) { | |
RETURN_FALSE; | |
} | |
@@ -156,7 +156,7 @@ static void sapi_run_header_callback(TSRMLS_D) | |
char *callback_error = NULL; | |
zval retval; | |
- if (zend_fcall_info_init(&SG(callback_func), 0, &fci, &SG(fci_cache), NULL, &callback_error TSRMLS_CC) == SUCCESS) { | |
+ if (zend_fcall_info_init(&SG(callback_func), 0, &fci, &SG(fci_cache), &callback_error TSRMLS_CC) == SUCCESS) { | |
fci.retval = &retval; | |
error = zend_call_function(&fci, &SG(fci_cache) TSRMLS_CC); | |
diff --git a/main/output.c b/main/output.c | |
index 2531dee..bbe10c8 100644 | |
--- a/main/output.c | |
+++ b/main/output.c | |
@@ -490,7 +490,7 @@ PHPAPI int php_output_start_internal(const char *name, size_t name_len, php_outp | |
* Create a user level output handler */ | |
PHPAPI php_output_handler *php_output_handler_create_user(zval *output_handler, size_t chunk_size, int flags TSRMLS_DC) | |
{ | |
- zend_string *handler_name = NULL; | |
+ zend_string *handler_name; | |
char *error = NULL; | |
php_output_handler *handler = NULL; | |
php_output_handler_alias_ctor_t alias = NULL; | |
@@ -507,10 +507,12 @@ PHPAPI php_output_handler *php_output_handler_create_user(zval *output_handler, | |
} | |
default: | |
user = ecalloc(1, sizeof(php_output_handler_user_func_t)); | |
- if (SUCCESS == zend_fcall_info_init(output_handler, 0, &user->fci, &user->fcc, &handler_name, &error TSRMLS_CC)) { | |
+ if (SUCCESS == zend_fcall_info_init(output_handler, 0, &user->fci, &user->fcc, &error TSRMLS_CC)) { | |
+ handler_name = zend_get_callable_name(output_handler, NULL TSRMLS_CC); | |
handler = php_output_handler_init(handler_name->val, handler_name->len, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_USER TSRMLS_CC); | |
ZVAL_COPY(&user->zoh, output_handler); | |
handler->func.user = user; | |
+ STR_RELEASE(handler_name); | |
} else { | |
efree(user); | |
} | |
@@ -518,9 +520,6 @@ PHPAPI php_output_handler *php_output_handler_create_user(zval *output_handler, | |
php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "%s", error); | |
efree(error); | |
} | |
- if (handler_name) { | |
- STR_RELEASE(handler_name); | |
- } | |
} | |
return handler; | |
diff --git a/main/streams/userspace.c b/main/streams/userspace.c | |
index a759f3d..290cfc6 100644 | |
--- a/main/streams/userspace.c | |
+++ b/main/streams/userspace.c | |
@@ -979,7 +979,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value | |
case PHP_STREAM_TRUNCATE_SUPPORTED: | |
if (zend_is_callable_ex(&func_name, | |
Z_ISUNDEF(us->object)? NULL : Z_OBJ(us->object), | |
- IS_CALLABLE_CHECK_SILENT, NULL, NULL, NULL TSRMLS_CC)) | |
+ IS_CALLABLE_CHECK_SILENT, NULL, NULL TSRMLS_CC)) | |
ret = PHP_STREAM_OPTION_RETURN_OK; | |
else | |
ret = PHP_STREAM_OPTION_RETURN_ERR; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment