]> source.dussan.org Git - rspamd.git/commitdiff
fix NULL pointer use when JIT compiling a regular expression. 3198/head
authorDirk Jagdmann <doj@cubic.org>
Thu, 26 Dec 2019 04:44:11 +0000 (20:44 -0800)
committerDirk Jagdmann <doj@cubic.org>
Thu, 26 Dec 2019 04:44:11 +0000 (20:44 -0800)
src/libutil/regexp.c

index 9bef43501a7b1b3609d4b3f86150022dddef863f..f36bd04f99fd19285af5835992f8749329c58edd 100644 (file)
@@ -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;
@@ -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);
                }
        }