From 025c9423e113bab57062c930799e298c4cba1c7d Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sun, 13 Sep 2026 15:26:58 -0400 Subject: [PATCH] device/deviceuiset: Fix GLSpectrumView use-after-free SpectrumVis retains a raw pointer to GLSpectrum while GLSpectrum is owned and destroyed by the Qt object hierarchy under DeviceUISet. DeviceUISet could therefore destroy GLSpectrum while the DSP thread still had access to the stale pointer through SpectrumVis. :( AddressSanitizer reported a use-after-free in: GLSpectrumView::updateSpectrumNoBuffer SpectrumVis::processFFT SpectrumVis::feed DSPDeviceSourceEngine::work with the GLSpectrumView destruction occurring from: GLSpectrumView::~GLSpectrumView() QObjectPrivate::deleteChildren() Clear the SpectrumVis GLSpectrum reference before destroying the Qt-owned GUI objects. This is safe with the DSP engine running because the SpectrumVis interface already treats the GLSpectrum reference as optional: processFFT() checks m_glSpectrum before using it. The GUI can therefore detach the spectrum visualization while DSP processing continues, after which the DSP path simply stops forwarding spectrum data to the deleted GUI object. Do not explicitly delete GLSpectrum here because its Qt parent owns it. Found by AddressSanitizer. Signed-off-by: Robin Getz --- sdrgui/device/deviceuiset.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sdrgui/device/deviceuiset.cpp b/sdrgui/device/deviceuiset.cpp index 36b63bdc0..8370760ea 100644 --- a/sdrgui/device/deviceuiset.cpp +++ b/sdrgui/device/deviceuiset.cpp @@ -79,6 +79,7 @@ DeviceUISet::DeviceUISet(int deviceSetIndex, DeviceSet *deviceSet) DeviceUISet::~DeviceUISet() { + m_spectrumVis->setGLSpectrum(nullptr); delete m_mainSpectrumGUI; }