From 0451a4038c84980afddd243d1343b27dadb9011f Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Tue, 18 Jun 2024 12:38:53 +0200 Subject: [PATCH] iosource/Manager: Do not manage lifetime of pkt_src Now that dry sources are properly reaped and freed, an offline packet source would be deleted once dry, resulting in GetPktSrc() returning a wild pointer. Don't manage the packet source lifetime and instead free it during Manager destruction. --- src/iosource/Manager.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/iosource/Manager.cc b/src/iosource/Manager.cc index 952bb13704..a7821e1a5f 100644 --- a/src/iosource/Manager.cc +++ b/src/iosource/Manager.cc @@ -76,6 +76,9 @@ Manager::~Manager() { pkt_dumpers.clear(); + // Was registered without lifetime management. + delete pkt_src; + #ifndef _MSC_VER // There's a bug here with builds on Windows that causes an assertion with debug builds // related to libkqueue returning a zero for the file descriptor. The assert happens @@ -357,7 +360,7 @@ void Manager::Register(IOSource* src, bool dont_count, bool manage_lifetime) { void Manager::Register(PktSrc* src) { pkt_src = src; - Register(src, false); + Register(src, false, false); // Once we know if the source is live or not, adapt the // poll_interval accordingly.