From: Victor Julien Date: Mon, 30 Jul 2018 15:04:57 +0000 (+0200) Subject: detect: avoid potential use-after-free in error path X-Git-Tag: suricata-4.1.0-rc2~180 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfa884c956d9afdc5362b69b4c87ca580c43fddf;p=thirdparty%2Fsuricata.git detect: avoid potential use-after-free in error path --- diff --git a/src/detect-engine.c b/src/detect-engine.c index 9fe7de6416..c5fa7e5e3f 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -2322,14 +2322,16 @@ TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data) det_ctx->counter_match_list = StatsRegisterAvgCounter("detect.match_list", tv); #endif - /* pass thread data back to caller */ - *data = (void *)det_ctx; - if (DetectEngineMultiTenantEnabled()) { - if (DetectEngineThreadCtxInitForMT(tv, det_ctx) != TM_ECODE_OK) + if (DetectEngineThreadCtxInitForMT(tv, det_ctx) != TM_ECODE_OK) { + DetectEngineThreadCtxDeinit(tv, det_ctx); return TM_ECODE_FAILED; + } } + /* pass thread data back to caller */ + *data = (void *)det_ctx; + return TM_ECODE_OK; }