Mission: protect against endless loops of do-commands

This commit is contained in:
Randy Mackay 2015-06-01 16:16:04 +09:00
parent c5f680de44
commit 9c28d61a5c

View File

@ -1068,6 +1068,9 @@ bool AP_Mission::advance_current_nav_cmd()
cmd_index++;
}
// avoid endless loops
uint8_t max_loops = 255;
// search until we find next nav command or reach end of command list
while (!_flags.nav_cmd_loaded) {
// get next command
@ -1089,6 +1092,11 @@ bool AP_Mission::advance_current_nav_cmd()
_do_cmd = cmd;
_flags.do_cmd_loaded = true;
_cmd_start_fn(_do_cmd);
} else {
// protect against endless loops of do-commands
if (max_loops-- == 0) {
return false;
}
}
}
// move onto next command