From 629acb8141e608b3d34eee576a7e121c7555d2c3 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 23 Feb 2022 13:41:42 +0100 Subject: [PATCH] unittests: clean up packet clear logic --- src/app-layer.c | 5 ++--- src/detect-hostbits.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/app-layer.c b/src/app-layer.c index bf51a3375f..4e64b3eb02 100644 --- a/src/app-layer.c +++ b/src/app-layer.c @@ -1112,7 +1112,7 @@ void AppLayerDeSetupCounters() #include "util-unittest.h" #define TEST_START \ - Packet *p = SCMalloc(SIZE_OF_PACKET); \ + Packet *p = PacketGetFromAlloc(); \ FAIL_IF_NULL(p); \ Flow f; \ ThreadVars tv; \ @@ -1198,8 +1198,7 @@ void AppLayerDeSetupCounters() StreamTcpSessionClear(p->flow->protoctx); \ StreamTcpThreadDeinit(&tv, (void *)stt); \ StreamTcpFreeConfig(true); \ - PACKET_DESTRUCTOR(p); \ - SCFree(p); \ + PacketFree(p); \ FLOW_DESTROY(&f); \ StatsThreadCleanup(&tv); diff --git a/src/detect-hostbits.c b/src/detect-hostbits.c index 03ebfb2267..a61ff14ece 100644 --- a/src/detect-hostbits.c +++ b/src/detect-hostbits.c @@ -555,7 +555,7 @@ static int HostBitsTestSig01(void) "Host: one.example.org\r\n" "\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); Signature *s = NULL; ThreadVars th_v; @@ -587,9 +587,8 @@ static int HostBitsTestSig01(void) DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); DetectEngineCtxFree(de_ctx); + PacketFree(p); HostBitsTestShutdown(); - - SCFree(p); PASS; } -- 2.47.2