1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-08-19 18:03:39 -04:00

Merge pull request #2880 from rgetz/rgetz-fix-resource-leaks

Fix resource ownership and cleanup issues across several SDRangel components.
This commit is contained in:
Edouard Griffiths
2026-08-16 06:15:24 +02:00
committed by GitHub
9 changed files with 72 additions and 6 deletions
@@ -41,6 +41,7 @@ ChannelAnalyzerSink::RRCHelper::RRCHelper(int flen) :
ChannelAnalyzerSink::RRCHelper::~RRCHelper()
{
delete m_filterFIR;
delete m_filterFFT;
delete[] m_buffer;
}
@@ -2979,6 +2979,16 @@ struct s2_fecdec : runnable
}
}
~s2_fecdec()
{
if (bitcount) {
delete bitcount;
}
if (errcount) {
delete errcount;
}
}
void run()
{
while (in.readable() >= 1 && out.writable() >= 1 &&
@@ -3292,6 +3302,12 @@ struct s2_fecdec_helper : runnable
{
free(command);
killall(); // also deletes pools[mc][sf].procs if necessary
if (bitcount) {
delete bitcount;
}
if (errcount) {
delete errcount;
}
}
void run()
@@ -4064,6 +4080,16 @@ struct s2_deframer : runnable
{
}
~s2_deframer()
{
if (state_out) {
delete state_out;
}
if (locktime_out) {
delete locktime_out;
}
}
void run()
{
while (in.readable() >= 1 && out.writable() >= MAX_TS_PER_BBFRAME &&
@@ -1301,11 +1301,7 @@ void FreqScanner::webapiFormatChannelSettings(
}
if (channelSettingsKeys.contains("frequencies") || force) {
QList<SWGSDRangel::SWGFreqScannerFrequency *> *frequencies = createFrequencyList(settings);
if (swgFreqScannerSettings->getFrequencies()) {
*swgFreqScannerSettings->getFrequencies() = *frequencies;
} else {
swgFreqScannerSettings->setFrequencies(frequencies);
}
swgFreqScannerSettings->setFrequencies(frequencies);
}
if (channelSettingsKeys.contains("rgbColor") || force) {
@@ -42,6 +42,16 @@ RadioAstronomyWorker::RadioAstronomyWorker(RadioAstronomy* radioAstronomy) :
RadioAstronomyWorker::~RadioAstronomyWorker()
{
m_inputMessageQueue.clear();
for (int i = 0; i < RADIOASTRONOMY_SENSORS; i++)
{
if (m_session[i] != VI_NULL)
{
m_visa.close(m_session[i]);
m_session[i] = VI_NULL;
}
}
m_visa.closeDefault();
}
@@ -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);
}
+6
View File
@@ -78,6 +78,12 @@ public:
{
update(mapItem);
}
~ObjectMapItem()
{
delete m_aircraftState;
}
void update(SWGSDRangel::SWGMapItem *mapItem) override;
protected:
@@ -752,5 +752,7 @@ void VorLocalizerWorker::rrNextTurn()
if (m_msgQueueToFeature) {
m_msgQueueToFeature->push(msg);
} else {
delete msg;
}
}
+21
View File
@@ -33,6 +33,9 @@ VISA::VISA() :
viClose(nullptr),
viPrintf(nullptr),
viScanf(nullptr),
viFindRsrc(nullptr),
viFindNext(nullptr),
visaLibrary(nullptr),
m_available(false)
{
#ifdef _MSC_VER
@@ -62,6 +65,14 @@ VISA::VISA() :
}
}
VISA::~VISA()
{
if (visaLibrary && (m_defaultRM == 0)) {
libraryClose(visaLibrary);
visaLibrary = nullptr;
}
}
ViSession VISA::openDefault()
{
if (isAvailable() && (m_defaultRM == 0))
@@ -267,6 +278,11 @@ void *VISA::libraryFunc(void *library, const char *function)
return GetProcAddress ((HMODULE)library, function);
}
void VISA::libraryClose(void *library)
{
FreeLibrary((HMODULE)library);
}
#else
void *VISA::libraryOpen(const char *filename)
@@ -279,4 +295,9 @@ void *VISA::libraryFunc(void *library, const char *function)
return dlsym (library, function);
}
void VISA::libraryClose(void *library)
{
dlclose(library);
}
#endif
+2
View File
@@ -74,6 +74,7 @@ public:
ViStatus (*viFindNext) (ViSession vi, ViChar desc[]);
VISA();
~VISA();
ViSession openDefault();
void closeDefault();
@@ -100,6 +101,7 @@ protected:
void *libraryOpen(const char *filename);
void *libraryFunc(void *library, const char *function);
void libraryClose(void *library);
};
#endif // INCLUDE_VISA_H