summaryrefslogtreecommitdiff
path: root/ext/pcre
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-09-21 10:29:36 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-09-21 10:29:36 +0200
commit48e9181519c54877e3e5ea7cd8a7653a90402056 (patch)
tree1f462265f9e30e2f68066c3da4eaded01b2444b6 /ext/pcre
parent64af12d13bc228dfacd953b93f83a009ed28e0b8 (diff)
parentd27dc5c028637edaf4d1511613cc33e7e164bd6e (diff)
downloadphp-git-48e9181519c54877e3e5ea7cd8a7653a90402056.tar.gz
Merge branch 'PHP-7.4' into master
* PHP-7.4: Fix #80118: Erroneous whitespace match with JIT only
Diffstat (limited to 'ext/pcre')
-rw-r--r--ext/pcre/pcre2lib/pcre2_jit_compile.c36
-rw-r--r--ext/pcre/tests/bug80118.phpt10
2 files changed, 38 insertions, 8 deletions
diff --git a/ext/pcre/pcre2lib/pcre2_jit_compile.c b/ext/pcre/pcre2lib/pcre2_jit_compile.c
index 8e51576ac6..61aa019d10 100644
--- a/ext/pcre/pcre2lib/pcre2_jit_compile.c
+++ b/ext/pcre/pcre2lib/pcre2_jit_compile.c
@@ -7594,25 +7594,43 @@ if (needstype || needsscript)
}
cc = ccbegin;
- }
- if (needschar)
- OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
+ if (needstype)
+ {
+ /* TMP2 has already been shifted by 2 */
+ if (!needschar)
+ {
+ OP2(SLJIT_ADD, TMP1, 0, TMP2, 0, TMP2, 0);
+ OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
+
+ OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));
+ }
+ else
+ {
+ OP2(SLJIT_ADD, TMP1, 0, TMP2, 0, TMP2, 0);
+ OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
- if (needstype)
+ OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
+ OP1(SLJIT_MOV_U8, RETURN_ADDR, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));
+ typereg = RETURN_ADDR;
+ }
+ }
+ else if (needschar)
+ OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
+ }
+ else if (needstype)
{
+ OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 3);
+ OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 2);
+
if (!needschar)
{
- OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 3);
- OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 2);
OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));
}
else
{
- OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 2);
- OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);
OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
@@ -7620,6 +7638,8 @@ if (needstype || needsscript)
typereg = RETURN_ADDR;
}
}
+ else if (needschar)
+ OP1(SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
}
#endif /* SUPPORT_UNICODE */
diff --git a/ext/pcre/tests/bug80118.phpt b/ext/pcre/tests/bug80118.phpt
new file mode 100644
index 0000000000..5de66076e0
--- /dev/null
+++ b/ext/pcre/tests/bug80118.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #80118 (Erroneous whitespace match with JIT only)
+--FILE--
+<?php
+preg_match('~[^\p{Han}\p{Z}]~u', ' ', $matches);
+var_dump($matches);
+?>
+--EXPECT--
+array(0) {
+}