Address the two largest leaks detected by valgrind when simply opening
and closing sdrangel with the 'X' button rather than the 'Exit' menu
item.
==11533== 18,016 (24 direct, 17,992 indirect) bytes in 1 blocks are definitely lost in loss record 6,991 of 7,005
==11533== at 0x4C2D54F: operator new(unsigned long) (vg_replace_malloc.c:334)
==11533== by 0x54C82ED: allocate (new_allocator.h:111)
==11533== by 0x54C82ED: allocate (alloc_traits.h:436)
==11533== by 0x54C82ED: _M_get_node (stl_list.h:383)
==11533== by 0x54C82ED: _M_create_node<FFTWEngine::Plan* const&> (stl_list.h:572)
==11533== by 0x54C82ED: _M_insert<FFTWEngine::Plan* const&> (stl_list.h:1801)
==11533== by 0x54C82ED: push_back (stl_list.h:1118)
==11533== by 0x54C82ED: FFTWEngine::configure(int, bool) (fftwengine.cpp:35)
==11533== by 0x4F4590B: SpectrumVis::handleConfigure(int, int, FFTWindow::Function) (spectrumvis.cpp:206)
==11533== by 0x4F45B94: SpectrumVis::SpectrumVis(float, GLSpectrum*) (spectrumvis.cpp:29)
==11533== by 0x4F46349: DeviceUISet::DeviceUISet(int, bool, QTimer&) (deviceuiset.cpp:39)
==11533== by 0x4EA890E: MainWindow::addSourceDevice(int) (mainwindow.cpp:240)
==11533== by 0x4EAC7F3: MainWindow::MainWindow(qtwebapp::LoggerWithFile*, MainParser const&, QWidget*) (mainwindow.cpp:171)
==11533== by 0x10A3B3: runQtApplication(int, char**, qtwebapp::LoggerWithFile*) (main.cpp:120)
==11533== by 0x109A78: main (main.cpp:130)
==11533==
==11533== 54,096 (112 direct, 53,984 indirect) bytes in 1 blocks are definitely lost in loss record 6,999 of 7,005
==11533== at 0x4C2D54F: operator new(unsigned long) (vg_replace_malloc.c:334)
==11533== by 0x69E9162: QObject::QObject(QObject*) (in /usr/lib/libQt5Core.so.5.10.1)
==11533== by 0x54834E6: BasebandSampleSink::BasebandSampleSink() (basebandsamplesink.cpp:6)
==11533== by 0x4F45A29: SpectrumVis::SpectrumVis(float, GLSpectrum*) (spectrumvis.cpp:26)
==11533== by 0x4F46349: DeviceUISet::DeviceUISet(int, bool, QTimer&) (deviceuiset.cpp:39)
==11533== by 0x4EA890E: MainWindow::addSourceDevice(int) (mainwindow.cpp:240)
==11533== by 0x4EAC7F3: MainWindow::MainWindow(qtwebapp::LoggerWithFile*, MainParser const&, QWidget*) (mainwindow.cpp:171)
==11533== by 0x10A3B3: runQtApplication(int, char**, qtwebapp::LoggerWithFile*) (main.cpp:120)
==11533== by 0x109A78: main (main.cpp:130)
The m_parms.tot_errs array is not initialized prior to its first use
in the RDSDemod::biphase function. ASAN does not pick up on this
directly, but instead reports it as follows (note that ASAN fills
memory with 0xBE and -1094795586 is 0xBEBEBEBE):
./plugins/channelrx/demodbfm/rdsdemod.cpp:159:95: runtime error: signed
integer overflow: -1094795586 + -1094795586 cannot be represented in type
'int'
The m_parms.subcarr_bb array does not appear to be read prior to
initialization, but we initialize it to zero anyway for the sake
of good hygiene.
UBSan reports the following error when replaying an IQ stream:
./plugins/samplesource/filesource/filesourcegui.cpp:331:29: runtime
error: signed integer overflow: 2704064 * 1000 cannot be represented
in type 'int'
By rearranging the calculation, we can be sure that the calculation never
overflows.
The RTPSession::CreateCNAME function checks to see if the buffer that
it is provided already has any data in it, and appends to it if so. The
RTPSession::InternalCreate function calls this function with an uninitialized
buffer, which results in indeterminate behavior. To ensure that the CNAME
is properly created, we clear the buffer before use.
==30323== Conditional jump or move depends on uninitialised value(s)
==30323== at 0x4C30109: __strlen_sse2 (vg_replace_strmem.c:460)
==30323== by 0x85647A4: qrtplib::RTPSession::CreateCNAME(unsigned char*, unsigned long*, bool) (rtpsession.cpp:1150)
==30323== by 0x8564B35: qrtplib::RTPSession::InternalCreate(qrtplib::RTPSessionParams const&) (rtpsession.cpp:218)
==30323== by 0x5499159: RTPSink::RTPSink(QUdpSocket*, int, bool) (rtpsink.cpp:48)
==30323== by 0x5420B6A: AudioNetSink::AudioNetSink(QObject*, int, bool) (audionetsink.cpp:42)
==30323== by 0x541F465: AudioOutput::start(int, int) (audiooutput.cpp:114)
==30323== by 0x5412763: AudioDeviceManager::startAudioOutput(int) (audiodevicemanager.cpp:361)
==30323== by 0x5412B0C: AudioDeviceManager::addAudioSink(AudioFifo*, MessageQueue*, int) (audiodevicemanager.cpp:229)
==30323== by 0x33F96DE7: BFMDemod::BFMDemod(DeviceSourceAPI*) (bfmdemod.cpp:56)
==30323== by 0x33FB03F2: non-virtual thunk to BFMPlugin::createRxChannelBS(DeviceSourceAPI*) (bfmplugin.cpp:62)
==30323== by 0x4F47F25: DeviceUISet::loadRxChannelSettings(Preset const*, PluginAPI*) (deviceuiset.cpp:199)
==30323== by 0x4EA51EA: MainWindow::loadPresetSettings(Preset const*, int) (mainwindow.cpp:575)
==30323== by 0x4EAC81B: MainWindow::MainWindow(qtwebapp::LoggerWithFile*, MainParser const&, QWidget*) (mainwindow.cpp:176)
==30323== by 0x10A49B: runQtApplication(int, char**, qtwebapp::LoggerWithFile*) (main.cpp:120)
==30323== by 0x109B38: main (main.cpp:131)