@@ -122,9 +122,11 @@ std::list<SMatch> Regex::searchAll(const std::string& s) const {
122
122
if (m_pcje == 0 ) {
123
123
rc = pcre2_jit_match (m_pc, pcre2_s, s.length (),
124
124
offset, 0 , match_data, NULL );
125
- } else {
125
+ }
126
+
127
+ if (m_pcje != 0 || rc == PCRE2_ERROR_JIT_STACKLIMIT) {
126
128
rc = pcre2_match (m_pc, pcre2_s, s.length (),
127
- offset, 0 , match_data, NULL );
129
+ offset, PCRE2_NO_JIT , match_data, NULL );
128
130
}
129
131
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer (match_data);
130
132
#else
@@ -168,8 +170,10 @@ bool Regex::searchOneMatch(const std::string& s, std::vector<SMatchCapture>& cap
168
170
int rc;
169
171
if (m_pcje == 0 ) {
170
172
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 );
173
177
}
174
178
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer (match_data);
175
179
#else
@@ -285,9 +289,11 @@ int Regex::search(const std::string& s, SMatch *match) const {
285
289
if (m_pcje == 0 ) {
286
290
ret = pcre2_match (m_pc, pcre2_s, s.length (),
287
291
0 , 0 , match_data, NULL ) > 0 ;
288
- } else {
292
+ }
293
+
294
+ if (m_pcje != 0 || rc == PCRE2_ERROR_JIT_STACKLIMIT) {
289
295
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 ;
291
297
}
292
298
if (ret > 0 ) { // match
293
299
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer (match_data);
@@ -316,8 +322,10 @@ int Regex::search(const std::string& s) const {
316
322
int rc;
317
323
if (m_pcje == 0 ) {
318
324
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 );
321
329
}
322
330
pcre2_match_data_free (match_data);
323
331
if (rc > 0 ) {
0 commit comments