From 3cad7cfa56f34ddfbd96867f7fd20aec297535ee Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 16 Nov 2023 12:37:08 +0100 Subject: [PATCH] unittests: free packet using PacketFree Update SigTest17 which left a dangling pointer. --- src/tests/detect.c | 3 --- src/util-unittest-helper.c | 23 +---------------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/src/tests/detect.c b/src/tests/detect.c index 302666ac85..37dc2cfe9b 100644 --- a/src/tests/detect.c +++ b/src/tests/detect.c @@ -1064,14 +1064,11 @@ static int SigTest17 (void) SigMatchSignatures(&th_v, de_ctx, det_ctx, p); uint32_t capid = VarNameStoreLookupByName("http_host", VAR_TYPE_PKT_VAR); - PktVar *pv_hn = PktVarGet(p, capid); FAIL_IF_NULL(pv_hn); - FAIL_IF(pv_hn->value_len != 15); FAIL_IF_NOT(memcmp(pv_hn->value, "one.example.org", pv_hn->value_len) == 0); - PktVarFree(pv_hn); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); DetectEngineCtxFree(de_ctx); ConfDeInit(); diff --git a/src/util-unittest-helper.c b/src/util-unittest-helper.c index 80356cf82e..48d2a045c1 100644 --- a/src/util-unittest-helper.c +++ b/src/util-unittest-helper.c @@ -486,28 +486,7 @@ void UTHFreePacket(Packet *p) { if (p == NULL) return; -#if 0 // VJ we now use one buffer - switch (p->proto) { - case IPPROTO_UDP: - if (p->udph != NULL) - SCFree(p->udph); - if (p->ip4h != NULL) - SCFree(p->ip4h); - break; - case IPPROTO_TCP: - if (p->tcph != NULL) - SCFree(p->tcph); - if (p->ip4h != NULL) - SCFree(p->ip4h); - break; - case IPPROTO_ICMP: - if (p->ip4h != NULL) - SCFree(p->ip4h); - break; - /* TODO: Add more protocols */ - } -#endif - SCFree(p); + PacketFree(p); } void UTHAssignFlow(Packet *p, Flow *f)