From b44ff3ee00ec2263deeb6a544f243e4844f18678 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Wed, 22 Jul 2026 19:52:58 -0400 Subject: [PATCH 1/4] RadioAstronomy: Guard aganst null FFT measurement RadioAstronomyGUI::spectrumSeries_clicked() called calcVrAndDistanceToPeak() without verifying that currentFFT() returned a valid FFTMeasurement. Since currentFFT() can return nullptr and calcVrAndDistanceToPeak() immediately dereferences the pointer, this could result in a null pointer dereference. Guard the calls so they are only made when a valid FFT measurement is available, matching the existing pattern used elsewhere in the class. Reported by Coverity (CID 649213). Signed-off-by: Robin Getz --- plugins/channelrx/radioastronomy/radioastronomygui.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/channelrx/radioastronomy/radioastronomygui.cpp b/plugins/channelrx/radioastronomy/radioastronomygui.cpp index ee14a7ed3..60d36b0d1 100644 --- a/plugins/channelrx/radioastronomy/radioastronomygui.cpp +++ b/plugins/channelrx/radioastronomy/radioastronomygui.cpp @@ -5799,7 +5799,9 @@ void RadioAstronomyGUI::spectrumSeries_clicked(const QPointF &point) m_spectrumM1Valid = true; ui->spectrumMarkerTable->item(SPECTRUM_MARKER_ROW_M1, SPECTRUM_MARKER_COL_FREQ)->setData(Qt::DisplayRole, m_spectrumM1X); ui->spectrumMarkerTable->item(SPECTRUM_MARKER_ROW_M1, SPECTRUM_MARKER_COL_VALUE)->setData(Qt::DisplayRole, m_spectrumM1Y); - calcVrAndDistanceToPeak(m_spectrumM1X*1e6, fft, SPECTRUM_MARKER_ROW_M1); + if (fft) { + calcVrAndDistanceToPeak(m_spectrumM1X*1e6, fft, SPECTRUM_MARKER_ROW_M1); + } } else if (selection == "M2") { @@ -5808,7 +5810,9 @@ void RadioAstronomyGUI::spectrumSeries_clicked(const QPointF &point) m_spectrumM2Valid = true; ui->spectrumMarkerTable->item(SPECTRUM_MARKER_ROW_M2, SPECTRUM_MARKER_COL_FREQ)->setData(Qt::DisplayRole, m_spectrumM2X); ui->spectrumMarkerTable->item(SPECTRUM_MARKER_ROW_M2, SPECTRUM_MARKER_COL_VALUE)->setData(Qt::DisplayRole, m_spectrumM2Y); - calcVrAndDistanceToPeak(m_spectrumM2X*1e6, fft, SPECTRUM_MARKER_ROW_M2); + if (fft) { + calcVrAndDistanceToPeak(m_spectrumM2X*1e6, fft, SPECTRUM_MARKER_ROW_M2); + } } calcSpectrumMarkerDelta(); From a637a20447e8117e9a519cc2f0c13160ecd4f4ed Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Wed, 22 Jul 2026 20:05:01 -0400 Subject: [PATCH 2/4] RadioAstronomy: Initialize sensor measurement range values Initialize m_min and m_max in the SensorMeasurements constructor to ensure the object has a valid state immediately after construction, before init() is called. Although init() sets these values before normal use, constructors should fully initialize all class members to avoid leaving objects with undefined state and to make the class safe to use regardless of initialization order. This fixes a Coverity UNINIT_CTOR warning caused by uninitialized scalar members in the constructor. Signed-off-by: Robin Getz --- plugins/channelrx/radioastronomy/radioastronomygui.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/channelrx/radioastronomy/radioastronomygui.h b/plugins/channelrx/radioastronomy/radioastronomygui.h index 6953d4f77..4f59baab3 100644 --- a/plugins/channelrx/radioastronomy/radioastronomygui.h +++ b/plugins/channelrx/radioastronomy/radioastronomygui.h @@ -186,7 +186,9 @@ class RadioAstronomyGUI : public ChannelGUI { SensorMeasurements() : m_series(nullptr), - m_yAxis(nullptr) + m_yAxis(nullptr), + m_max(-std::numeric_limits::max()), + m_min(std::numeric_limits::max()) { } From 10d9d503c7816c7d8e9cdaad55814f3be8b2ca45 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Wed, 22 Jul 2026 20:20:30 -0400 Subject: [PATCH 3/4] RadioAstronomy: Initialize FFT measurement fields Initialize previously unset FFTMeasurement members with defined default values so newly constructed measurement objects start in a known state. Although these fields are populated during normal measurement processing, constructors should establish a complete and deterministic object state rather than leaving scalar members with indeterminate values. This also makes the class safer if the initialization sequence changes in the future. This fixes a Coverity UNINIT_CTOR warning caused by uninitialized scalar members in the constructor. Signed-off-by: Robin Getz --- .../radioastronomy/radioastronomygui.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/channelrx/radioastronomy/radioastronomygui.h b/plugins/channelrx/radioastronomy/radioastronomygui.h index 4f59baab3..d841be792 100644 --- a/plugins/channelrx/radioastronomy/radioastronomygui.h +++ b/plugins/channelrx/radioastronomy/radioastronomygui.h @@ -96,7 +96,7 @@ class RadioAstronomyGUI : public ChannelGUI { float m_solarFlux; float m_airTemp; float m_skyTemp; - float m_sensor[RADIOASTRONOMY_SENSORS]; + float m_sensor[RADIOASTRONOMY_SENSORS] {0.0f}; bool m_rotValid; float m_rotAz; @@ -107,6 +107,10 @@ class RadioAstronomyGUI : public ChannelGUI { int m_sweepIndex; FFTMeasurement() : + m_centerFrequency(0), + m_sampleRate(0), + m_integration(0), + m_rfBandwidth(0), m_fftSize(0), m_fftData(nullptr), m_db(nullptr), @@ -124,7 +128,18 @@ class RadioAstronomyGUI : public ChannelGUI { m_sigmaS(0.0f), m_tempMin(0.0f), m_baseline(RadioAstronomySettings::SBL_TSYS0), + m_omegaA(0.0f), + m_omegaS(0.0f), m_coordsValid(false), + m_ra(0.0f), + m_dec(0.0f), + m_azimuth(0.0f), + m_elevation(0.0f), + m_l(0.0f), + m_b(0.0f), + m_vBCRS(0.0f), + m_vLSR(0.0f), + m_solarFlux(0.0f), m_airTemp(0.0), m_skyTemp(0.0), m_rotValid(false), From 68aea9c16f29c1276fe0c01ea197df23b72d4890 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Wed, 22 Jul 2026 20:37:16 -0400 Subject: [PATCH 4/4] RadioAstronomy: Apply channel settings only after dialog acceptance Only apply channel settings after BasicChannelSettingsDialog returns an accepted result. Previously, the return value from dialog.exec() was ignored and settings were copied from the dialog regardless of whether the dialog was accepted or rejected. This could cause changes made in the channel settings dialog to be applied even when the user discarded them. Check the dialog result before updating the channel title, color, Reverse API configuration, and stream index to keep the GUI state synchronized with the user's action. This also fixes the Coverity CHECKED_RETURN warning for the unchecked QDialog::exec() return value. Signed-off-by: Robin Getz --- .../radioastronomy/radioastronomygui.cpp | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/plugins/channelrx/radioastronomy/radioastronomygui.cpp b/plugins/channelrx/radioastronomy/radioastronomygui.cpp index 60d36b0d1..0aae52abc 100644 --- a/plugins/channelrx/radioastronomy/radioastronomygui.cpp +++ b/plugins/channelrx/radioastronomy/radioastronomygui.cpp @@ -2061,31 +2061,32 @@ void RadioAstronomyGUI::onMenuDialogCalled(const QPoint &p) dialog.move(p); new DialogPositioner(&dialog, false); - dialog.exec(); - - m_settings.m_rgbColor = m_channelMarker.getColor().rgb(); - m_settings.m_title = m_channelMarker.getTitle(); - m_settings.m_useReverseAPI = dialog.useReverseAPI(); - m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress(); - m_settings.m_reverseAPIPort = dialog.getReverseAPIPort(); - m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex(); - m_settings.m_reverseAPIChannelIndex = dialog.getReverseAPIChannelIndex(); - - setWindowTitle(m_settings.m_title); - setTitle(m_channelMarker.getTitle()); - setTitleColor(m_settings.m_rgbColor); - - if (m_deviceUISet->m_deviceMIMOEngine) + if (dialog.exec() == QDialog::Accepted) { - m_settings.m_streamIndex = dialog.getSelectedStreamIndex(); - m_channelMarker.clearStreamIndexes(); - m_channelMarker.addStreamIndex(m_settings.m_streamIndex); - updateIndexLabel(); - } + m_settings.m_rgbColor = m_channelMarker.getColor().rgb(); + m_settings.m_title = m_channelMarker.getTitle(); + m_settings.m_useReverseAPI = dialog.useReverseAPI(); + m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress(); + m_settings.m_reverseAPIPort = dialog.getReverseAPIPort(); + m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex(); + m_settings.m_reverseAPIChannelIndex = dialog.getReverseAPIChannelIndex(); - applySettings(QStringList({"title", "rgbColor", "useReverseAPI", "reverseAPIAddress", - "reverseAPIPort", "reverseAPIDeviceIndex", "reverseAPIChannelIndex", - "streamIndex"})); + setWindowTitle(m_settings.m_title); + setTitle(m_channelMarker.getTitle()); + setTitleColor(m_settings.m_rgbColor); + + if (m_deviceUISet->m_deviceMIMOEngine) + { + m_settings.m_streamIndex = dialog.getSelectedStreamIndex(); + m_channelMarker.clearStreamIndexes(); + m_channelMarker.addStreamIndex(m_settings.m_streamIndex); + updateIndexLabel(); + } + + applySettings(QStringList({"title", "rgbColor", "useReverseAPI", "reverseAPIAddress", + "reverseAPIPort", "reverseAPIDeviceIndex", "reverseAPIChannelIndex", + "streamIndex"})); + } } resetContextMenuType();