]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
unittests: clean up packet clear logic
authorVictor Julien <vjulien@oisf.net>
Wed, 23 Feb 2022 12:41:42 +0000 (13:41 +0100)
committerVictor Julien <vjulien@oisf.net>
Thu, 24 Feb 2022 17:23:30 +0000 (18:23 +0100)
src/app-layer.c
src/detect-hostbits.c

index bf51a3375fca956120aef397a3cfbd7145965ebd..4e64b3eb0266b7a921ab43cfccd99cd788b03ebc 100644 (file)
@@ -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);
 
index 03ebfb2267375b4fc579e564c97b345188fc941c..a61ff14eced6fa471075e79f2ac1e91cd931daac 100644 (file)
@@ -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;
 }