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 <rgetz503@gmail.com>
This commit is contained in:
Robin Getz
2026-08-01 19:40:15 -04:00
parent c9c95398f3
commit edc4693448
+1 -1
View File
@@ -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;
}