]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow: cleanup expectations first
authorVictor Julien <victor@inliniac.net>
Fri, 3 Apr 2020 08:09:07 +0000 (10:09 +0200)
committerVictor Julien <victor@inliniac.net>
Sat, 25 Apr 2020 17:53:39 +0000 (19:53 +0200)
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.

(cherry picked from commit 09a21545ce00de8ef161f097603f98770351e9be)

src/flow.c

index c7a8617ee071b033eb66cd265dc29a8e21bd15d8..dc196eda176a8fe0b01920064ab08861a4f11b59 100644 (file)
@@ -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);