From edc4693448541fe1a53e873c45dbf15396bb270b Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sat, 1 Aug 2026 19:40:15 -0400 Subject: [PATCH] rtl-sdr: Fix out-of-bounds access in gain selection The gain change handler allowed an index equal to m_gains.size(), which is outside the valid vector range. Reject invalid indices before accessing the gain table to avoid undefined behavior. found with cppcheck: Access out of bounds Signed-off-by: Robin Getz --- plugins/samplesource/rtlsdr/rtlsdrgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp index 6cde4e82c..1399637ae 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp @@ -394,7 +394,7 @@ void RTLSDRGui::on_ppm_valueChanged(int value) void RTLSDRGui::on_gain_valueChanged(int value) { - if (value > (int)m_gains.size()) { + if (value < 0 || value >= (int)m_gains.size()) { return; }