From 4498bc62b24d6847ed6f4cd54b5c388b23c8ed1e Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sun, 9 Aug 2026 18:22:34 -0400 Subject: [PATCH] udpsource: avoid leaking sample rate correction messages Only allocate `MsgSampleRateCorrection` when a feedback message queue is available. The message was previously allocated before checking `m_autoRWBalance` and `m_feedbackMessageQueue`. When either condition was false, the message was never queued and its allocation was leaked. Coverity CID 652413 reported a `RESOURCE_LEAK` after tracing the allocation from `MsgSampleRateCorrection::create()` to the point where the local pointer went out of scope without being transferred to the feedback queue. Signed-off-by: Robin Getz --- plugins/channeltx/udpsource/udpsourceudphandler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/channeltx/udpsource/udpsourceudphandler.cpp b/plugins/channeltx/udpsource/udpsourceudphandler.cpp index 9a4605093..8f4aecf0a 100644 --- a/plugins/channeltx/udpsource/udpsourceudphandler.cpp +++ b/plugins/channeltx/udpsource/udpsourceudphandler.cpp @@ -223,9 +223,11 @@ void UDPSourceUDPHandler::advanceReadPointer(int nbBytes) float dd = d - m_d; // derivative float c = (d / 15.0) + (dd / 20.0); // damping and scaling c = c < -0.05 ? -0.05 : c > 0.05 ? 0.05 : c; // limit - UDPSourceMessages::MsgSampleRateCorrection *msg = UDPSourceMessages::MsgSampleRateCorrection::create(c, d); if (m_autoRWBalance && m_feedbackMessageQueue) { + // create and immediately transfer ownership to queue + UDPSourceMessages::MsgSampleRateCorrection *msg = + UDPSourceMessages::MsgSampleRateCorrection::create(c, d); m_feedbackMessageQueue->push(msg); }