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
This commit is contained in:
Randy Mackay 2021-03-15 12:00:15 +09:00
parent 2c95093d36
commit b873e7fcb0

View File

@ -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