Merge branch 'PHP-7.3' into PHP-7.4

This commit is contained in:
Nikita Popov 2019-03-19 13:59:43 +01:00
commit 2783670daa
4 changed files with 20 additions and 11 deletions

View file

@ -2500,7 +2500,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); match_data = pcre2_match_data_create_from_pattern(pce->re, gctx);
if (!match_data) { if (!match_data) {
PCRE_G(error_code) = PHP_PCRE_INTERNAL_ERROR; PCRE_G(error_code) = PHP_PCRE_INTERNAL_ERROR;
return; zval_ptr_dtor(return_value);
RETURN_FALSE;
} }
} }
@ -2620,6 +2621,11 @@ error:
pcre2_match_data_free(match_data); pcre2_match_data_free(match_data);
} }
if (PCRE_G(error_code) != PHP_PCRE_NO_ERROR) {
zval_ptr_dtor(return_value);
RETURN_FALSE;
}
last: last:
start_offset = (last_match - ZSTR_VAL(subject_str)); /* the offset might have been incremented, but without further successful matches */ start_offset = (last_match - ZSTR_VAL(subject_str)); /* the offset might have been incremented, but without further successful matches */

View file

@ -5,8 +5,7 @@ Bug #70345 (Multiple vulnerabilities related to PCRE functions)
$regex = '/(?=xyz\K)/'; $regex = '/(?=xyz\K)/';
$subject = "aaaaxyzaaaa"; $subject = "aaaaxyzaaaa";
$v = preg_split($regex, $subject); var_dump(preg_split($regex, $subject));
print_r($v);
$regex = '/(a(?=xyz\K))/'; $regex = '/(a(?=xyz\K))/';
$subject = "aaaaxyzaaaa"; $subject = "aaaaxyzaaaa";
@ -14,10 +13,7 @@ preg_match($regex, $subject, $matches);
var_dump($matches); var_dump($matches);
--EXPECTF-- --EXPECTF--
Array bool(false)
(
[0] => aaaaxyzaaaa
)
Warning: preg_match(): Get subpatterns list failed in %s on line %d Warning: preg_match(): Get subpatterns list failed in %s on line %d
array(0) { array(0) {

View file

@ -0,0 +1,10 @@
--TEST--
Bug #76127: preg_split does not raise an error on invalid UTF-8
--FILE--
<?php
var_dump(preg_split("/a/u", "a\xff"));
var_dump(preg_last_error() == PREG_BAD_UTF8_ERROR);
?>
--EXPECT--
bool(false)
bool(true)

View file

@ -310,8 +310,5 @@ array(6) {
Warning: preg_last_error() expects exactly 0 parameters, 1 given in %s on line %d Warning: preg_last_error() expects exactly 0 parameters, 1 given in %s on line %d
NULL NULL
bool(true) bool(true)
array(1) { bool(false)
[0]=>
string(6) "ab2c3u"
}
bool(true) bool(true)