Skip to content

Commit ff90aee

Browse files
committed
Merge branch 'PHP-7.2'
* PHP-7.2: Fixed bug #75089 (preg_grep() is not reporting PREG_BAD_UTF8_ERROR after first input string)
2 parents 3acfdbb + ef90e37 commit ff90aee

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

ext/pcre/php_pcre.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,7 +2537,7 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return
25372537
int *offsets; /* Array of subpattern offsets */
25382538
int size_offsets; /* Size of the offsets array */
25392539
int count = 0; /* Count of matched subpatterns */
2540-
int no_utf_check = 0; /* Execution options */
2540+
int no_utf_check; /* Execution options */
25412541
zend_string *string_key;
25422542
zend_ulong num_key;
25432543
zend_bool invert; /* Whether to return non-matching
@@ -2569,18 +2569,13 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return
25692569

25702570
PCRE_G(error_code) = PHP_PCRE_NO_ERROR;
25712571

2572-
#ifdef HAVE_PCRE_JIT_SUPPORT
2573-
if (!(pce->compile_options & PCRE_UTF8)) {
2574-
no_utf_check = PCRE_NO_UTF8_CHECK;
2575-
}
2576-
#endif
2577-
25782572
/* Go through the input array */
25792573
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(input), num_key, string_key, entry) {
25802574
zend_string *subject_str = zval_get_string(entry);
25812575

25822576
/* Perform the match */
25832577
#ifdef HAVE_PCRE_JIT_SUPPORT
2578+
no_utf_check = (pce->compile_options & PCRE_UTF8) ? 0 : PCRE_NO_UTF8_CHECK;
25842579
if ((extra->flags & PCRE_EXTRA_EXECUTABLE_JIT)
25852580
&& no_utf_check) {
25862581
count = pcre_jit_exec(pce->re, extra, ZSTR_VAL(subject_str),

ext/pcre/tests/bug75089.phpt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Bug #75089 (preg_grep() is not reporting PREG_BAD_UTF8_ERROR after first input string)
3+
--FILE--
4+
<?php
5+
preg_grep('#\d#u', ['a', "1\xFF"/*, 'c'*/]);
6+
var_dump(preg_last_error());
7+
?>
8+
--EXPECT--
9+
int(4)

0 commit comments

Comments
 (0)