diff --git a/src/decode.c b/src/decode.c index 1aa964c5f1..17ca90b3bc 100644 --- a/src/decode.c +++ b/src/decode.c @@ -82,6 +82,19 @@ int DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, return TM_ECODE_OK; } +static inline void PacketFreeExtData(Packet *p) +{ + /* if p uses extended data, free them */ + if (p->ext_pkt) { + if (!(p->flags & PKT_ZERO_COPY)) { + SCFree(p->ext_pkt); + } + p->ext_pkt = NULL; + } +} + + + /** * \brief Return a malloced packet. */ @@ -140,6 +153,7 @@ Packet *PacketGetFromAlloc(void) */ void PacketFreeOrRelease(Packet *p) { + PacketFreeExtData(p); if (p->flags & PKT_ALLOC) PacketFree(p); else diff --git a/src/tmqh-packetpool.c b/src/tmqh-packetpool.c index 531af50c33..ec4a4fe116 100644 --- a/src/tmqh-packetpool.c +++ b/src/tmqh-packetpool.c @@ -273,14 +273,6 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p) p->root = NULL; } - /* if p uses extended data, free them */ - if (p->ext_pkt) { - if (!(p->flags & PKT_ZERO_COPY)) { - SCFree(p->ext_pkt); - } - p->ext_pkt = NULL; - } - PACKET_PROFILING_END(p); p->ReleasePacket(p);