Browse Source

AP_Mission: correct off-by-one check when fetching mission items

master
Peter Barker 8 years ago committed by Randy Mackay
parent
commit
591bb32496
  1. 2
      libraries/AP_Mission/AP_Mission.cpp
  2. 1
      libraries/AP_Mission/AP_Mission.h

2
libraries/AP_Mission/AP_Mission.cpp

@ -429,7 +429,7 @@ bool AP_Mission::set_current_cmd(uint16_t index) @@ -429,7 +429,7 @@ bool AP_Mission::set_current_cmd(uint16_t index)
bool AP_Mission::read_cmd_from_storage(uint16_t index, Mission_Command& cmd) const
{
// exit immediately if index is beyond last command but we always let cmd #0 (i.e. home) be read
if (index > (unsigned)_cmd_total && index != 0) {
if (index >= (unsigned)_cmd_total && index != 0) {
return false;
}

1
libraries/AP_Mission/AP_Mission.h

@ -294,6 +294,7 @@ public: @@ -294,6 +294,7 @@ public:
mission_state state() const { return _flags.state; }
/// num_commands - returns total number of commands in the mission
/// this number includes offset 0, the home location
uint16_t num_commands() const { return _cmd_total; }
/// num_commands_max - returns maximum number of commands that can be stored

Loading…
Cancel
Save