unittests: free memory for proto tests

pull/14025/head
Victor Julien 10 months ago committed by Victor Julien
parent 37ad70ab59
commit ec6536ba75

@ -129,6 +129,7 @@ int DetectProtoContainsProto(const DetectProto *dp, int proto)
#include "detect-engine.h"
#include "detect-parse.h"
#include "detect-engine-mpm.h"
/**
* \brief this function is used to initialize the detection engine context and
* setup the signature with passed values.
@ -138,32 +139,31 @@ static int DetectProtoInitTest(DetectEngineCtx **de_ctx, Signature **sig,
{
char fullstr[1024];
int result = 0;
static uint32_t test_sid = 1;
*de_ctx = NULL;
*sig = NULL;
if (snprintf(fullstr, 1024, "alert %s any any -> any any (msg:\"DetectProto"
" test\"; sid:1;)", str) >= 1024)
{
if (snprintf(fullstr, 1024,
"alert %s any any -> any any (msg:\"DetectProto"
" test\"; sid:%u;)",
str, test_sid++) >= 1024) {
goto end;
}
if (*de_ctx == NULL) {
*de_ctx = DetectEngineCtxInit();
if (*de_ctx == NULL) {
goto end;
}
(*de_ctx)->flags |= DE_QUIET;
(*de_ctx)->sig_list = SigInit(*de_ctx, fullstr);
if ((*de_ctx)->sig_list == NULL) {
goto end;
}
*sig = (*de_ctx)->sig_list;
if (DetectProtoParse(dp, str) < 0)
Signature *s = DetectEngineAppendSig(*de_ctx, fullstr);
if (s == NULL) {
goto end;
}
*sig = s;
result = 1;

Loading…
Cancel
Save