summaryrefslogtreecommitdiff
path: root/ext/pcre/php_pcre.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2019-11-22 19:21:43 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2019-11-22 19:26:26 +0100
commite1da72bdf18aa3d413c5324bccfd8dc521c217e3 (patch)
tree89949464983945c9452e572bc55df6c91f048c8e /ext/pcre/php_pcre.c
parente981f5af51bf2a16965aad68ae268021dc251c9c (diff)
downloadphp-git-e1da72bdf18aa3d413c5324bccfd8dc521c217e3.tar.gz
Fix #78853: preg_match() may return integer > 1
Commit 54ebebd[1] optimized the match loop, but for this case it has been overlooked, that we must only loop if we're doing global matching. [1] <http://git.php.net/?p=php-src.git;a=commit;h=54ebebd686255c5f124af718c966edb392782d4a>
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r--ext/pcre/php_pcre.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 882389e1ce..38eabe2556 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -1344,7 +1344,11 @@ matched:
count = pcre2_match(pce->re, (PCRE2_SPTR)subject, subject_len, start_offset2,
PCRE2_NO_UTF_CHECK | PCRE2_NOTEMPTY_ATSTART | PCRE2_ANCHORED, match_data, mctx);
if (count >= 0) {
- goto matched;
+ if (global) {
+ goto matched;
+ } else {
+ break;
+ }
} else if (count == PCRE2_ERROR_NOMATCH) {
/* If we previously set PCRE2_NOTEMPTY_ATSTART after a null match,
this is not necessarily the end. We need to advance