From e219ec144ef6682b71e135fd18654ee1bb4676b4 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 7 Jan 2019 12:28:51 +0100 Subject: Implement typed properties RFC: https://wiki.php.net/rfc/typed_properties_v2 This is a squash of PR #3734, which is a squash of PR #3313. Co-authored-by: Bob Weinand Co-authored-by: Joe Watkins Co-authored-by: Dmitry Stogov --- ext/pcre/php_pcre.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'ext/pcre/php_pcre.c') diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 16ebedd7ac..8622ea8c65 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -970,7 +970,7 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ * Z_PARAM_STR(regex) Z_PARAM_STR(subject) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_DEREF(subpats) + Z_PARAM_ZVAL(subpats) Z_PARAM_LONG(flags) Z_PARAM_LONG(start_offset) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); @@ -1014,8 +1014,10 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, size_t sub /* Overwrite the passed-in value for subpatterns with an empty array. */ if (subpats != NULL) { - zval_ptr_dtor(subpats); - array_init(subpats); + subpats = zend_try_array_init(subpats); + if (!subpats) { + return; + } } subpats_order = global ? PREG_PATTERN_ORDER : 0; @@ -2239,7 +2241,7 @@ static void preg_replace_common(INTERNAL_FUNCTION_PARAMETERS, int is_filter) Z_PARAM_ZVAL(subject) Z_PARAM_OPTIONAL Z_PARAM_LONG(limit) - Z_PARAM_ZVAL_DEREF(zcount) + Z_PARAM_ZVAL(zcount) ZEND_PARSE_PARAMETERS_END(); if (Z_TYPE_P(replace) != IS_ARRAY) { @@ -2305,8 +2307,7 @@ static void preg_replace_common(INTERNAL_FUNCTION_PARAMETERS, int is_filter) } if (zcount) { - zval_ptr_dtor(zcount); - ZVAL_LONG(zcount, replace_count); + ZEND_TRY_ASSIGN_LONG(zcount, replace_count); } } /* }}} */ @@ -2336,7 +2337,7 @@ static PHP_FUNCTION(preg_replace_callback) Z_PARAM_ZVAL(subject) Z_PARAM_OPTIONAL Z_PARAM_LONG(limit) - Z_PARAM_ZVAL_DEREF(zcount) + Z_PARAM_ZVAL(zcount) ZEND_PARSE_PARAMETERS_END(); if (!zend_is_callable_ex(replace, NULL, 0, NULL, &fcc, NULL)) { @@ -2353,8 +2354,7 @@ static PHP_FUNCTION(preg_replace_callback) replace_count = preg_replace_func_impl(return_value, regex, &fci, &fcc, subject, limit); if (zcount) { - zval_ptr_dtor(zcount); - ZVAL_LONG(zcount, replace_count); + ZEND_TRY_ASSIGN_LONG(zcount, replace_count); } } /* }}} */ @@ -2376,7 +2376,7 @@ static PHP_FUNCTION(preg_replace_callback_array) Z_PARAM_ZVAL(subject) Z_PARAM_OPTIONAL Z_PARAM_LONG(limit) - Z_PARAM_ZVAL_DEREF(zcount) + Z_PARAM_ZVAL(zcount) ZEND_PARSE_PARAMETERS_END(); fci.size = sizeof(fci); @@ -2421,8 +2421,7 @@ static PHP_FUNCTION(preg_replace_callback_array) } ZEND_HASH_FOREACH_END(); if (zcount) { - zval_ptr_dtor(zcount); - ZVAL_LONG(zcount, replace_count); + ZEND_TRY_ASSIGN_LONG(zcount, replace_count); } } /* }}} */ -- cgit v1.2.1