From b44ff3ee00ec2263deeb6a544f243e4844f18678 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Wed, 22 Jul 2026 19:52:58 -0400 Subject: [PATCH] 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();