Skip to content

Commit

Permalink
Merge pull request #3198 from doj/master
Browse files Browse the repository at this point in the history
[Minor] Fix NULL pointer use when JIT compiling a regular expression.
  • Loading branch information
vstakhov committed Dec 26, 2019
2 parents a1410d8 + 89e6c7b commit d54c078
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libutil/regexp.c
Expand Up @@ -199,7 +199,7 @@ rspamd_regexp_post_process (rspamd_regexp_t *r)
pcre2_jit_stack_assign (r->mcontext, NULL, global_re_cache->jstack);
}

if (r->re != r->raw_re && !(r->flags & RSPAMD_REGEXP_FLAG_DISABLE_JIT)) {
if (r->raw_re && r->re != r->raw_re && !(r->flags & RSPAMD_REGEXP_FLAG_DISABLE_JIT)) {
if (pcre2_jit_compile (r->raw_re, jit_flags) < 0) {
msg_debug ("jit compilation of %s is not supported", r->pattern);
r->flags |= RSPAMD_REGEXP_FLAG_DISABLE_JIT;
Expand All @@ -209,6 +209,7 @@ rspamd_regexp_post_process (rspamd_regexp_t *r)
msg_debug ("jit compilation of raw %s is not supported", r->pattern);
}
else if (!(r->flags & RSPAMD_REGEXP_FLAG_DISABLE_JIT)) {
g_assert (r->raw_mcontext != NULL);
pcre2_jit_stack_assign (r->raw_mcontext, NULL, global_re_cache->jstack);
}
}
Expand Down

0 comments on commit d54c078

Please sign in to comment.