nsh: check nsh_consolemain return value

Starting a new console allocates memory dynamically, which can fail.
This commit is contained in:
Niklas Hauser
2023-08-29 11:56:40 +02:00
committed by Daniel Agar
parent cde47e8fc0
commit af40d5befd
2 changed files with 8 additions and 2 deletions
+7 -1
View File
@@ -186,7 +186,13 @@ int MavlinkShell::shell_start_thread(int argc, char *argv[])
#ifdef __PX4_NUTTX
dup2(1, 2); //redirect stderror to stdout
nsh_consolemain(0, NULL);
const int ret = nsh_consolemain(0, NULL);
if (ret) {
PX4_ERR("Mavlink shell failed: %d%s", ret, (ret == -ENOMEM) ? " (out of memory)" : "");
return ret;
}
#endif /* __PX4_NUTTX */
#ifdef __PX4_POSIX