From: Victor Julien Date: Mon, 17 Sep 2018 14:44:55 +0000 (+0200) Subject: detect/template: clean up unittest X-Git-Tag: suricata-4.1.0-rc2~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=234d113838de5d4e46a0d7e362d0b378178e4229;p=thirdparty%2Fsuricata.git detect/template: clean up unittest --- diff --git a/src/detect-template-buffer.c b/src/detect-template-buffer.c index 0f02f2b39a..82b6ead6d3 100644 --- a/src/detect-template-buffer.c +++ b/src/detect-template-buffer.c @@ -125,8 +125,8 @@ static int DetectEngineInspectTemplateBuffer(ThreadVars *tv, static int DetectTemplateBufferTest(void) { AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); - DetectEngineThreadCtx *det_ctx = NULL; - DetectEngineCtx *de_ctx = NULL; + FAIL_IF_NULL(alp_tctx); + Flow f; Packet *p; TcpSession tcp; @@ -150,7 +150,7 @@ static int DetectTemplateBufferTest(void) p->flowflags |= FLOW_PKT_TOSERVER | FLOW_PKT_ESTABLISHED; StreamTcpInitConfig(TRUE); - de_ctx = DetectEngineCtxInit(); + DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); /* This rule should match. */ @@ -170,7 +170,10 @@ static int DetectTemplateBufferTest(void) FAIL_IF_NULL(s); SigGroupBuild(de_ctx); + + DetectEngineThreadCtx *det_ctx = NULL; DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx); + FAIL_IF_NULL(det_ctx); FLOWLOCK_WRLOCK(&f); AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TEMPLATE, @@ -185,14 +188,9 @@ static int DetectTemplateBufferTest(void) FAIL_IF(PacketAlertCheck(p, 2)); /* Cleanup. */ - if (alp_tctx != NULL) - AppLayerParserThreadCtxFree(alp_tctx); - if (det_ctx != NULL) - DetectEngineThreadCtxDeinit(&tv, det_ctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - DetectEngineCtxFree(de_ctx); + AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&tv, det_ctx); + DetectEngineCtxFree(de_ctx); StreamTcpFreeConfig(TRUE); FLOW_DESTROY(&f); UTHFreePacket(p);