]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
decode: release refs from PacketFree
authorVictor Julien <vjulien@oisf.net>
Wed, 23 Feb 2022 12:40:59 +0000 (13:40 +0100)
committerJeff Lucovsky <jeff@lucovsky.org>
Fri, 11 Mar 2022 14:03:32 +0000 (09:03 -0500)
Mostly helps unittests.

(cherry picked from commit f07d5b2d89ed27d075e9f9328fd678d6ea701889)

src/decode.h
src/tmqh-packetpool.c

index ddb4a105f2552712163db4fabc89c5d003ea551a..825bd9cfae2324e2dedad89d06e5ff6346341e97 100644 (file)
@@ -827,17 +827,18 @@ void CaptureStatsSetup(ThreadVars *tv, CaptureStats *s);
 /**
  *  \brief Cleanup a packet so that we can free it. No memset needed..
  */
-#define PACKET_DESTRUCTOR(p) do {                  \
-        if ((p)->pktvar != NULL) {              \
-            PktVarFree((p)->pktvar);            \
-        }                                       \
-        PACKET_FREE_EXTDATA((p));               \
-        SCMutexDestroy(&(p)->tunnel_mutex);     \
-        AppLayerDecoderEventsFreeEvents(&(p)->app_layer_events); \
-        PACKET_PROFILING_RESET((p));            \
+#define PACKET_DESTRUCTOR(p)                                                                       \
+    do {                                                                                           \
+        PACKET_RELEASE_REFS((p));                                                                  \
+        if ((p)->pktvar != NULL) {                                                                 \
+            PktVarFree((p)->pktvar);                                                               \
+        }                                                                                          \
+        PACKET_FREE_EXTDATA((p));                                                                  \
+        SCMutexDestroy(&(p)->tunnel_mutex);                                                        \
+        AppLayerDecoderEventsFreeEvents(&(p)->app_layer_events);                                   \
+        PACKET_PROFILING_RESET((p));                                                               \
     } while (0)
 
-
 /* macro's for setting the action
  * handle the case of a root packet
  * for tunnels */
index cea1212197b7ae782606c2c79994b300a21888e8..9a5fdaa47e7aef6324b2178c1c8b481987a770b5 100644 (file)
@@ -289,14 +289,14 @@ Packet *PacketPoolGetPacket(void)
 void PacketPoolReturnPacket(Packet *p)
 {
     PktPool *my_pool = GetThreadPacketPool();
-
-    PACKET_RELEASE_REFS(p);
-
     PktPool *pool = p->pool;
     if (pool == NULL) {
         PacketFree(p);
         return;
     }
+
+    PACKET_RELEASE_REFS(p);
+
 #ifdef DEBUG_VALIDATION
     BUG_ON(pool->initialized == 0);
     BUG_ON(pool->destroyed == 1);