From c170e03dddaf4b76d6b438ebf17658bb00c617cd Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sat, 1 Aug 2026 19:52:09 -0400 Subject: [PATCH] rtl-sdr: Fix out-of-bounds tuner name lookup Validate the tuner type index before accessing the tuner name table. The previous check allowed an index equal to names.size(), which could result in an out-of-range QStringList access. Use a local integer value for the enum conversion and ensure only valid indices are used when looking up tuner names. pointed out by cppcheck: Access out of bounds Signed-off-by: Robin Getz --- plugins/samplesource/rtlsdr/rtlsdrinput.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp index 82ea15cd9..b5497ef9b 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp @@ -469,8 +469,10 @@ QString RTLSDRInput::getTunerName() const { const static QStringList names = {"Unknown", "E4000", "FC0012", "FC0013", "FC2580", "R820T", "R828D"}; - if ((int) m_tunerType <= names.size()) { - return names[(int) m_tunerType]; + const int tunerType = (int) m_tunerType; + + if (tunerType >= 0 && tunerType < names.size()) { + return names[tunerType]; } else { return names[0]; }