From: Victor Julien Date: Wed, 23 Feb 2022 12:41:42 +0000 (+0100) Subject: unittests: clean up packet clear logic X-Git-Tag: suricata-7.0.0-beta1~847 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0437ca61ff81e3597a00e1e11311f4e9dc7182a5;p=thirdparty%2Fsuricata.git unittests: clean up packet clear logic --- 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; }