Browse Source

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
zr-v5.1
Randy Mackay 4 years ago
parent
commit
b873e7fcb0
  1. 6
      libraries/AP_Mission/AP_Mission.cpp

6
libraries/AP_Mission/AP_Mission.cpp

@ -625,9 +625,8 @@ bool AP_Mission::read_cmd_from_storage(uint16_t index, Mission_Command& cmd) con @@ -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 @@ -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

Loading…
Cancel
Save