com php-src: refix bug #70895: Zend/zend_API.c
| From: | Anatol Belski | Date: | Thu, 12 Nov 2015 00:39:02 +0000 |
| Subject: | com php-src: refix bug #70895: Zend/zend_API.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89760@lists.php.net to get a copy of this message | ||
Commit: 93240102e0830802ca1b27ccabd9a899a1de7570
Author: Anatol Belski <ab@php.net> Thu, 12 Nov 2015 01:39:02 +0100
Parents: 8eef11d3179fe7c6fed8393c1bbae96fcab05c49
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=93240102e0830802ca1b27ccabd9a899a1de7570
Log:
refix bug #70895
move this code to where it belongs, no behavior change to actual
throwing function, thus retaining compat with old ZPP
Bugs:
https://bugs.php.net/70895
Changed paths:
M Zend/zend_API.c
Diff:
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 0abaccd..c595a13 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -242,17 +242,37 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity,
in
const char *space;
const char *class_name = get_active_class_name(&space);
+ size_t error_len = strlen(error), sanitized_error_len = error_len, k = 0, n = 0;
+ char *sanitized_error = emalloc(sizeof(char) * error_len);
+
+ while (k < error_len) {
+ sanitized_error[n] = error[k];
+ if ('%' == error[k]) {
+ n++;
+ sanitized_error[n] = '%';
+ }
+ k++;
+ n++;
+
+ if (n == sanitized_error_len) {
+ sanitized_error_len += error_len - k;
+ sanitized_error = erealloc(sanitized_error, sanitized_error_len);
+ }
+ }
+ sanitized_error[n] = '\0';
+
if (severity == E_WARNING) {
zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be
a valid callback, %s",
- class_name, space, get_active_function_name(), num, error);
+ class_name, space, get_active_function_name(), num, sanitized_error);
} else if (severity == E_ERROR) {
zend_throw_error(zend_ce_type_error, "%s%s%s() expects parameter %d to be a valid callback,
%s",
- class_name, space, get_active_function_name(), num, error);
+ class_name, space, get_active_function_name(), num, sanitized_error);
} else {
zend_error(severity, "%s%s%s() expects parameter %d to be a valid callback, %s",
- class_name, space, get_active_function_name(), num, error);
+ class_name, space, get_active_function_name(), num, sanitized_error);
}
efree(error);
+ efree(sanitized_error);
}
/* }}} */
@@ -2989,28 +3009,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable,
zend_fca
} else {
/* We already checked for plain function before. */
if (error && !(check_flags & IS_CALLABLE_CHECK_SILENT)) {
- size_t callable_name_len = Z_STRLEN_P(callable), sanitized_callable_name_len =
Z_STRLEN_P(callable), k = 0, n = 0;
- char *callable_name = Z_STRVAL_P(callable), *sanitized_callable_name = emalloc(sizeof(char) *
callable_name_len);
-
- while (k < callable_name_len) {
- sanitized_callable_name[n] = callable_name[k];
- if ('%' == callable_name[k]) {
- n++;
- sanitized_callable_name[n] = '%';
- }
- k++;
- n++;
-
- if (n == sanitized_callable_name_len) {
- sanitized_callable_name_len += callable_name_len - k;
- sanitized_callable_name = erealloc(sanitized_callable_name, sanitized_callable_name_len);
- }
- }
- sanitized_callable_name[n] = '\0';
-
- zend_spprintf(error, 0, "function '%s' not found or invalid function name",
sanitized_callable_name);
-
- efree(sanitized_callable_name);
+ zend_spprintf(error, 0, "function '%s' not found or invalid function name",
Z_STRVAL_P(callable));
}
return 0;
}