From b873e7fcb097cef3dddfc1f312f16cfd2c7bd8df Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Mon, 15 Mar 2021 12:00:15 +0900 Subject: [PATCH] AP_Mission: read_cmd_from_storage sets all bytes of cmd This resolves a potential valgrind issue caused by some bytes of the cmd not being set --- libraries/AP_Mission/AP_Mission.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Mission/AP_Mission.cpp b/libraries/AP_Mission/AP_Mission.cpp index 4cbdc8ee98..db60034894 100644 --- a/libraries/AP_Mission/AP_Mission.cpp +++ b/libraries/AP_Mission/AP_Mission.cpp @@ -625,9 +625,8 @@ bool AP_Mission::read_cmd_from_storage(uint16_t index, Mission_Command& cmd) con // special handling for command #0 which is home if (index == 0) { - cmd.index = 0; + cmd = {}; cmd.id = MAV_CMD_NAV_WAYPOINT; - cmd.p1 = 0; cmd.content.location = AP::ahrs().get_home(); return true; } @@ -636,6 +635,9 @@ bool AP_Mission::read_cmd_from_storage(uint16_t index, Mission_Command& cmd) con return false; } + // ensure all bytes of cmd are zeroed + cmd = {}; + // Find out proper location in memory by using the start_byte position + the index // we can load a command, we don't process it yet // read WP position