Browse Source

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 <rgetz503@gmail.com>
chirpmodem-v8.0.0
Robin Getz 4 months ago
parent
commit
4498bc62b2
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 4
      plugins/channeltx/udpsource/udpsourceudphandler.cpp

4
plugins/channeltx/udpsource/udpsourceudphandler.cpp

@ -223,9 +223,11 @@ void UDPSourceUDPHandler::advanceReadPointer(int nbBytes) @@ -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);
}

Loading…
Cancel
Save