From ea0f5fa790f46d3f0fc2d4fa9726b6dddf42c9a4 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sun, 19 Jul 2026 19:26:39 -0400 Subject: [PATCH] NoiseFigure: Prevent divide by zero when plotting reference data Fix Coverity CID 649238 (DIVIDE_BY_ZERO) by validating the reference column count before using it as a divisor in plotChart(). The reference column count can be cleared when removing reference data, in on_clearReference_clicked() so ensure chart rendering handles an empty reference configuration safely. Signed-off-by: Robin Getz --- plugins/channelrx/noisefigure/noisefiguregui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/channelrx/noisefigure/noisefiguregui.cpp b/plugins/channelrx/noisefigure/noisefiguregui.cpp index 6708ad91f..23cb28c8f 100644 --- a/plugins/channelrx/noisefigure/noisefiguregui.cpp +++ b/plugins/channelrx/noisefigure/noisefiguregui.cpp @@ -102,7 +102,7 @@ void NoiseFigureGUI::plotChart() // Create reference data series QLineSeries *ref = nullptr; - if ((m_refData.size() > 0) && (ui->chartSelect->currentIndex() < m_refCols-1)) { + if ((m_refData.size() > 0) && (m_refCols > 0) && (ui->chartSelect->currentIndex() < m_refCols-1)) { ref = new QLineSeries(); for (int i = 0; i < m_refData.size() / m_refCols; i++) { ref->append(m_refData[i*m_refCols], m_refData[i*m_refCols+ui->chartSelect->currentIndex()+1]);