summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_mbregex.c
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-05-18 20:32:21 +0200
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-07-28 17:06:25 +0200
commitac0da090ae25b370721f2d0b26e5d60c61f1c93b (patch)
tree5ac969a9e13f008b474d9cf1fd184b9dcf68516b /ext/mbstring/php_mbregex.c
parent118fa69e70ef7543c417244c845e06a260e9edae (diff)
downloadphp-git-ac0da090ae25b370721f2d0b26e5d60c61f1c93b.tar.gz
Fix UNKNOWN default values in ext/mbstring and ext/gd
Closes GH-5598
Diffstat (limited to 'ext/mbstring/php_mbregex.c')
-rw-r--r--ext/mbstring/php_mbregex.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index a797efbf7b..85309e7cfd 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -852,7 +852,7 @@ PHP_FUNCTION(mb_regex_encoding)
char *encoding = NULL;
size_t encoding_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &encoding, &encoding_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!", &encoding, &encoding_len) == FAILURE) {
RETURN_THROWS();
}
@@ -1030,7 +1030,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
size_t option_str_len = 0;
if (!is_callable) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|s",
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|s!",
&arg_pattern, &arg_pattern_len,
&replace, &replace_len,
&string, &string_len,
@@ -1038,7 +1038,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
RETURN_THROWS();
}
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sfs|s",
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sfs|s!",
&arg_pattern, &arg_pattern_len,
&arg_replace_fci, &arg_replace_fci_cache,
&string, &string_len,
@@ -1297,7 +1297,7 @@ PHP_FUNCTION(mb_ereg_match)
char *option_str = NULL;
size_t option_str_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|s",
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|s!",
&arg_pattern, &arg_pattern_len, &string, &string_len,
&option_str, &option_str_len)==FAILURE) {
RETURN_THROWS();
@@ -1340,8 +1340,7 @@ PHP_FUNCTION(mb_ereg_match)
/* regex search */
/* {{{ _php_mb_regex_ereg_search_exec */
-static void
-_php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode)
+static void _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
char *arg_pattern = NULL, *arg_options = NULL;
size_t arg_pattern_len, arg_options_len;
@@ -1353,7 +1352,7 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode)
OnigUChar *str;
OnigSyntaxType *syntax;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!", &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) {
RETURN_THROWS();
}
@@ -1485,24 +1484,24 @@ PHP_FUNCTION(mb_ereg_search_init)
OnigSyntaxType *syntax = NULL;
OnigOptionType option;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|ss", &arg_str, &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|s!s!", &arg_str, &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) {
RETURN_THROWS();
}
- if (ZEND_NUM_ARGS() > 1 && arg_pattern_len == 0) {
+ if (arg_pattern && arg_pattern_len == 0) {
php_error_docref(NULL, E_WARNING, "Empty pattern");
RETURN_FALSE;
}
- option = MBREX(regex_default_options);
- syntax = MBREX(regex_default_syntax);
-
- if (ZEND_NUM_ARGS() == 3) {
+ if (arg_options) {
option = 0;
_php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, NULL);
+ } else {
+ option = MBREX(regex_default_options);
+ syntax = MBREX(regex_default_syntax);
}
- if (ZEND_NUM_ARGS() > 1) {
+ if (arg_pattern) {
/* create regex pattern buffer */
if ((MBREX(search_re) = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, option, syntax)) == NULL) {
RETURN_FALSE;
@@ -1515,11 +1514,7 @@ PHP_FUNCTION(mb_ereg_search_init)
ZVAL_STR_COPY(&MBREX(search_str), arg_str);
- if (php_mb_check_encoding(
- ZSTR_VAL(arg_str),
- ZSTR_LEN(arg_str),
- php_mb_regex_get_mbctype_encoding()
- )) {
+ if (php_mb_check_encoding(ZSTR_VAL(arg_str), ZSTR_LEN(arg_str), php_mb_regex_get_mbctype_encoding())) {
MBREX(search_pos) = 0;
RETVAL_TRUE;
} else {
@@ -1635,7 +1630,7 @@ PHP_FUNCTION(mb_regex_set_options)
size_t string_len;
char buf[16];
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s",
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!",
&string, &string_len) == FAILURE) {
RETURN_THROWS();
}