From 661bce47aebdc67bda1616e1b6979803765173a6 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 19 Mar 2019 13:57:39 +0100 Subject: Fixed bug #76127 Per documentation, and consistent with other preg functions, we should return false if an error occurred. --- ext/pcre/php_pcre.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'ext/pcre/php_pcre.c') diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index a7c1a93646..db469a576f 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -2517,7 +2517,8 @@ PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, zend_string *subject_str, match_data = pcre2_match_data_create_from_pattern(pce->re, gctx); if (!match_data) { PCRE_G(error_code) = PHP_PCRE_INTERNAL_ERROR; - return; + zval_ptr_dtor(return_value); + RETURN_FALSE; } } @@ -2637,6 +2638,11 @@ error: pcre2_match_data_free(match_data); } + if (PCRE_G(error_code) != PHP_PCRE_NO_ERROR) { + zval_ptr_dtor(return_value); + RETURN_FALSE; + } + last: start_offset = (last_match - ZSTR_VAL(subject_str)); /* the offset might have been incremented, but without further successful matches */ -- cgit v1.2.1