diff options
author | George Peter Banyard <girgias@php.net> | 2020-06-22 15:46:23 +0200 |
---|---|---|
committer | George Peter Banyard <girgias@php.net> | 2020-06-22 15:56:36 +0200 |
commit | 1a2732f9a8b3d62471b360f772b5458f78046f80 (patch) | |
tree | 86d60a6a36ee3a0e6464eb6f1b33a8531594a938 /ext/pcre/php_pcre.c | |
parent | 26171c3690874743e1c71766e60248fbd974782f (diff) | |
download | php-git-1a2732f9a8b3d62471b360f772b5458f78046f80.tar.gz |
Use ZPP callable check for preg_replace_callback() $callback argument
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r-- | ext/pcre/php_pcre.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 2ed5d9d7dd..98fa437bec 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -2369,7 +2369,7 @@ PHP_FUNCTION(preg_replace) Perform Perl-style regular expression replacement using replacement callback. */ PHP_FUNCTION(preg_replace_callback) { - zval *regex, *replace, *subject, *zcount = NULL; + zval *regex, *subject, *zcount = NULL; zend_long limit = -1, flags = 0; size_t replace_count; zend_fcall_info fci; @@ -2378,7 +2378,7 @@ PHP_FUNCTION(preg_replace_callback) /* Get function parameters and do error-checking. */ ZEND_PARSE_PARAMETERS_START(3, 6) Z_PARAM_ZVAL(regex) - Z_PARAM_ZVAL(replace) + Z_PARAM_FUNC(fci, fcc) Z_PARAM_ZVAL(subject) Z_PARAM_OPTIONAL Z_PARAM_LONG(limit) @@ -2386,18 +2386,6 @@ PHP_FUNCTION(preg_replace_callback) Z_PARAM_LONG(flags) ZEND_PARSE_PARAMETERS_END(); - if (!zend_is_callable_ex(replace, NULL, 0, NULL, &fcc, NULL)) { - zend_string *callback_name = zend_get_callable_name(replace); - php_error_docref(NULL, E_WARNING, "Requires argument 2, '%s', to be a valid callback", ZSTR_VAL(callback_name)); - zend_string_release_ex(callback_name, 0); - ZVAL_STR(return_value, zval_get_string(subject)); - return; - } - - fci.size = sizeof(fci); - fci.object = NULL; - ZVAL_COPY_VALUE(&fci.function_name, replace); - replace_count = preg_replace_func_impl(return_value, regex, &fci, &fcc, subject, limit, flags); if (zcount) { ZEND_TRY_ASSIGN_REF_LONG(zcount, replace_count); |