summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/pcre/php_pcre.c6
-rw-r--r--ext/pcre/tests/bug78853.phpt8
2 files changed, 13 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
diff --git a/ext/pcre/tests/bug78853.phpt b/ext/pcre/tests/bug78853.phpt
new file mode 100644
index 0000000000..369ed0f926
--- /dev/null
+++ b/ext/pcre/tests/bug78853.phpt
@@ -0,0 +1,8 @@
+--TEST--
+Bug #78853 (preg_match() may return integer > 1)
+--FILE--
+<?php
+var_dump(preg_match('/^|\d{1,2}$/', "7"));
+?>
+--EXPECT--
+int(1)