From 09a21545ce00de8ef161f097603f98770351e9be Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 3 Apr 2020 10:09:07 +0200 Subject: [PATCH] flow: cleanup expectations first Make sure to cleanup expectations for a flow as the first step, before parts of the flow itself are getting cleaned/freed. Also indicate use unlikely as flows with expectations should be relatively rare. --- src/flow.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/flow.c b/src/flow.c index fce1ae3f31..7f7ea6f8c0 100644 --- a/src/flow.c +++ b/src/flow.c @@ -1046,6 +1046,10 @@ int FlowClearMemory(Flow* f, uint8_t proto_map) { SCEnter(); + if (unlikely(f->flags & FLOW_HAS_EXPECTATION)) { + AppLayerExpectationClean(f); + } + /* call the protocol specific free function if we have one */ if (flow_freefuncs[proto_map].Freefunc != NULL) { flow_freefuncs[proto_map].Freefunc(f->protoctx); @@ -1053,9 +1057,6 @@ int FlowClearMemory(Flow* f, uint8_t proto_map) FlowFreeStorage(f); - if (f->flags & FLOW_HAS_EXPECTATION) - AppLayerExpectationClean(f); - FLOW_RECYCLE(f); SCReturnInt(1); -- 2.47.2