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