Skip to content

Commit cfb643c

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78853: preg_match() may return integer > 1
2 parents 99b8e67 + e1da72b commit cfb643c

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ PHP NEWS
1818
. Fixed $x = (bool)$x; with opcache (should emit undeclared variable notice).
1919
(Tyson Andre)
2020

21+
- PCRE:
22+
. Fixed bug #78853 (preg_match() may return integer > 1). (cmb)
23+
2124
?? ??? ????, PHP 7.4.0RC6
2225

2326
- Core:

ext/pcre/php_pcre.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,11 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str,
13591359
count = pcre2_match(pce->re, (PCRE2_SPTR)subject, subject_len, start_offset2,
13601360
PCRE2_NO_UTF_CHECK | PCRE2_NOTEMPTY_ATSTART | PCRE2_ANCHORED, match_data, mctx);
13611361
if (count >= 0) {
1362-
goto matched;
1362+
if (global) {
1363+
goto matched;
1364+
} else {
1365+
break;
1366+
}
13631367
} else if (count == PCRE2_ERROR_NOMATCH) {
13641368
/* If we previously set PCRE2_NOTEMPTY_ATSTART after a null match,
13651369
this is not necessarily the end. We need to advance

ext/pcre/tests/bug78853.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
Bug #78853 (preg_match() may return integer > 1)
3+
--FILE--
4+
<?php
5+
var_dump(preg_match('/^|\d{1,2}$/', "7"));
6+
?>
7+
--EXPECT--
8+
int(1)

0 commit comments

Comments
 (0)