Skip to content

Commit 1550e30

Browse files
authored
add fallback for JIT_STACKLIMIT
1 parent 6518973 commit 1550e30

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/operators/verify_cc.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ bool VerifyCC::evaluate(Transaction *t, RuleWithActions *rule,
148148

149149
if (m_pcje == 0) {
150150
ret = pcre2_jit_match(m_pc, pcre2_i, target_length, offset, 0, match_data, NULL);
151-
} else {
152-
ret = pcre2_match(m_pc, pcre2_i, target_length, offset, 0, match_data, NULL);
151+
}
152+
153+
if (m_pcje != 0 || ret == PCRE2_ERROR_JIT_STACKLIMIT) {
154+
ret = pcre2_match(m_pc, pcre2_i, target_length, offset, PCRE2_NO_JIT, match_data, NULL);
153155
}
154156

155157
/* If there was no match, then we are done. */

src/utils/regex.cc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ std::list<SMatch> Regex::searchAll(const std::string& s) const {
122122
if (m_pcje == 0) {
123123
rc = pcre2_jit_match(m_pc, pcre2_s, s.length(),
124124
offset, 0, match_data, NULL);
125-
} else {
125+
}
126+
127+
if (m_pcje != 0 || rc == PCRE2_ERROR_JIT_STACKLIMIT) {
126128
rc = pcre2_match(m_pc, pcre2_s, s.length(),
127-
offset, 0, match_data, NULL);
129+
offset, PCRE2_NO_JIT, match_data, NULL);
128130
}
129131
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(match_data);
130132
#else
@@ -168,8 +170,10 @@ bool Regex::searchOneMatch(const std::string& s, std::vector<SMatchCapture>& cap
168170
int rc;
169171
if (m_pcje == 0) {
170172
rc = pcre2_jit_match(m_pc, pcre2_s, s.length(), 0, 0, match_data, NULL);
171-
} else {
172-
rc = pcre2_match(m_pc, pcre2_s, s.length(), 0, 0, match_data, NULL);
173+
}
174+
175+
if (m_pcje != 0 || rc == PCRE2_ERROR_JIT_STACKLIMIT) {
176+
rc = pcre2_match(m_pc, pcre2_s, s.length(), 0, PCRE2_NO_JIT, match_data, NULL);
173177
}
174178
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(match_data);
175179
#else
@@ -285,9 +289,11 @@ int Regex::search(const std::string& s, SMatch *match) const {
285289
if (m_pcje == 0) {
286290
ret = pcre2_match(m_pc, pcre2_s, s.length(),
287291
0, 0, match_data, NULL) > 0;
288-
} else {
292+
}
293+
294+
if (m_pcje != 0 || rc == PCRE2_ERROR_JIT_STACKLIMIT) {
289295
ret = pcre2_match(m_pc, pcre2_s, s.length(),
290-
0, 0, match_data, NULL) > 0;
296+
0, PCRE2_NO_JIT, match_data, NULL) > 0;
291297
}
292298
if (ret > 0) { // match
293299
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(match_data);
@@ -316,8 +322,10 @@ int Regex::search(const std::string& s) const {
316322
int rc;
317323
if (m_pcje == 0) {
318324
rc = pcre2_jit_match(m_pc, pcre2_s, s.length(), 0, 0, match_data, NULL);
319-
} else {
320-
rc = pcre2_match(m_pc, pcre2_s, s.length(), 0, 0, match_data, NULL);
325+
}
326+
327+
if (m_pcje != 0 || rc == PCRE2_ERROR_JIT_STACKLIMIT) {
328+
rc = pcre2_match(m_pc, pcre2_s, s.length(), 0, PCRE2_NO_JIT, match_data, NULL);
321329
}
322330
pcre2_match_data_free(match_data);
323331
if (rc > 0) {

0 commit comments

Comments
 (0)