desktop: fixed 2 crashes in the menu code

handle an empty line gracefully, and use pgm_read_pointer() for
functions pointers in progmem
This commit is contained in:
Andrew Tridgell 2011-11-07 20:51:19 +11:00
parent 152da9c91b
commit 75d7ee01d1

View File

@ -87,6 +87,10 @@ Menu::run(void)
argc++;
}
if (_argv[0].str == NULL) {
continue;
}
// populate arguments that have not been specified with "" and 0
// this is safer than NULL in the case where commands may look
// without testing argc
@ -136,6 +140,6 @@ Menu::_call(uint8_t n, uint8_t argc)
{
func fn;
fn = (func)pgm_read_word(&_commands[n].func);
fn = (func)pgm_read_pointer(&_commands[n].func);
return(fn(argc, &_argv[0]));
}