Browse Source

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

Fix resource ownership and cleanup issues across several SDRangel components.
chirpmodem-v8.0.0
Edouard Griffiths 3 months ago committed by GitHub
parent
commit
d8feb80e98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      plugins/channelrx/chanalyzer/chanalyzersink.cpp
  2. 26
      plugins/channelrx/demoddatv/leansdr/dvbs2.h
  3. 6
      plugins/channelrx/freqscanner/freqscanner.cpp
  4. 10
      plugins/channelrx/radioastronomy/radioastronomyworker.cpp
  5. 4
      plugins/channeltx/udpsource/udpsourceudphandler.cpp
  6. 6
      plugins/feature/map/mapitem.h
  7. 2
      plugins/feature/vorlocalizer/vorlocalizerworker.cpp
  8. 21
      sdrbase/util/visa.cpp
  9. 2
      sdrbase/util/visa.h

1
plugins/channelrx/chanalyzer/chanalyzersink.cpp

@ -41,6 +41,7 @@ ChannelAnalyzerSink::RRCHelper::RRCHelper(int flen) : @@ -41,6 +41,7 @@ ChannelAnalyzerSink::RRCHelper::RRCHelper(int flen) :
ChannelAnalyzerSink::RRCHelper::~RRCHelper()
{
delete m_filterFIR;
delete m_filterFFT;
delete[] m_buffer;
}

26
plugins/channelrx/demoddatv/leansdr/dvbs2.h

@ -2979,6 +2979,16 @@ struct s2_fecdec : runnable @@ -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 @@ -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 @@ -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 &&

6
plugins/channelrx/freqscanner/freqscanner.cpp

@ -1301,11 +1301,7 @@ void FreqScanner::webapiFormatChannelSettings( @@ -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) {

10
plugins/channelrx/radioastronomy/radioastronomyworker.cpp

@ -42,6 +42,16 @@ RadioAstronomyWorker::RadioAstronomyWorker(RadioAstronomy* radioAstronomy) : @@ -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();
}

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);
}

6
plugins/feature/map/mapitem.h

@ -78,6 +78,12 @@ public: @@ -78,6 +78,12 @@ public:
{
update(mapItem);
}
~ObjectMapItem()
{
delete m_aircraftState;
}
void update(SWGSDRangel::SWGMapItem *mapItem) override;
protected:

2
plugins/feature/vorlocalizer/vorlocalizerworker.cpp

@ -752,5 +752,7 @@ void VorLocalizerWorker::rrNextTurn() @@ -752,5 +752,7 @@ void VorLocalizerWorker::rrNextTurn()
if (m_msgQueueToFeature) {
m_msgQueueToFeature->push(msg);
} else {
delete msg;
}
}

21
sdrbase/util/visa.cpp

@ -33,6 +33,9 @@ VISA::VISA() : @@ -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() : @@ -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) @@ -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) @@ -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
sdrbase/util/visa.h

@ -74,6 +74,7 @@ public: @@ -74,6 +74,7 @@ public:
ViStatus (*viFindNext) (ViSession vi, ViChar desc[]);
VISA();
~VISA();
ViSession openDefault();
void closeDefault();
@ -100,6 +101,7 @@ protected: @@ -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

Loading…
Cancel
Save