AP_Menu: avoid segmentation fault

Insufficient input would cause a segfault
This commit is contained in:
Peter Barker 2015-07-10 21:48:24 +10:00 committed by Andrew Tridgell
parent 3dfb447fd7
commit 39b2cdcc3c
1 changed files with 1 additions and 1 deletions

View File

@ -106,7 +106,7 @@ Menu::_run_command(bool prompt_on_enter)
// XXX should an empty line by itself back out of the current menu? // XXX should an empty line by itself back out of the current menu?
while (argc <= _args_max) { while (argc <= _args_max) {
_argv[argc].str = strtok_r(NULL, " ", &s); _argv[argc].str = strtok_r(NULL, " ", &s);
if ('\0' == _argv[argc].str[0]) if (_argv[argc].str == NULL || '\0' == _argv[argc].str[0])
break; break;
_argv[argc].i = atol(_argv[argc].str); _argv[argc].i = atol(_argv[argc].str);
_argv[argc].f = atof(_argv[argc].str); // calls strtod, > 700B ! _argv[argc].f = atof(_argv[argc].str); // calls strtod, > 700B !