Skip to content

Commit 29653da

Browse files
committed
Fixed bug #74873 (Minor BC break: PCRE_JIT changes output of preg_match()).
1 parent 5a991ea commit 29653da

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ PHP NEWS
2121
. Fixed bug #74651 (negative-size-param (-1) in memcpy in zif_openssl_seal()).
2222
(Stas)
2323

24+
- PCRE:
25+
. Fixed bug #74873 (Minor BC break: PCRE_JIT changes output of preg_match()).
26+
(Dmitry)
27+
2428
06 Jul 2017, PHP 7.2.0alpha3
2529

2630
- Core:

ext/pcre/php_pcre.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,10 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
826826
#ifdef HAVE_PCRE_JIT_SUPPORT
827827
if ((extra->flags & PCRE_EXTRA_EXECUTABLE_JIT)
828828
&& no_utf_check && !g_notempty) {
829+
if (start_offset < 0 || start_offset > subject_len) {
830+
pcre_handle_exec_error(PCRE_ERROR_BADOFFSET);
831+
break;
832+
}
829833
count = pcre_jit_exec(pce->re, extra, subject, (int)subject_len, (int)start_offset,
830834
no_utf_check|g_notempty, offsets, size_offsets, jit_stack);
831835
} else

ext/pcre/tests/bug74873.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
Bug #74873 (Minor BC break: PCRE_JIT changes output of preg_match())
3+
--FILE--
4+
<?php
5+
var_dump(preg_match('/\S+/', 'foo bar', $matches, 0, 99999));
6+
?>
7+
--EXPECT--
8+
bool(false)

0 commit comments

Comments
 (0)