From d20fd16a1483cb1d65a678a1ffda1fcebf042434 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Wed, 21 Sep 2022 08:45:04 +0100 Subject: [PATCH] AP_VideoTX: fix potential buffer overrun bug --- libraries/AP_VideoTX/AP_VideoTX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/AP_VideoTX/AP_VideoTX.cpp b/libraries/AP_VideoTX/AP_VideoTX.cpp index 704cc9d082..33db195150 100644 --- a/libraries/AP_VideoTX/AP_VideoTX.cpp +++ b/libraries/AP_VideoTX/AP_VideoTX.cpp @@ -515,7 +515,7 @@ void AP_VideoTX::change_power(int8_t position) debug("looking for pos %d power level %d from %d", position, level, num_active_levels); uint16_t power = 0; for (uint8_t i = 0, j = 0; i < num_active_levels; i++, j++) { - while (_power_levels[j].active == PowerActive::Inactive && j < VTX_MAX_POWER_LEVELS-1) { + while (j < VTX_MAX_POWER_LEVELS-1 && _power_levels[j].active == PowerActive::Inactive) { j++; } if (i == level) {