mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 10:23:36 +08:00
failure command: fix array bound seg fault with e.g. failure motor -i 1
This commit is contained in:
@@ -175,12 +175,6 @@ extern "C" __EXPORT int failure_main(int argc, char *argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 3) {
|
|
||||||
PX4_ERR("Not enough arguments.");
|
|
||||||
print_usage();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *myoptarg = nullptr;
|
const char *myoptarg = nullptr;
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
int myoptind = 1;
|
int myoptind = 1;
|
||||||
@@ -200,6 +194,12 @@ extern "C" __EXPORT int failure_main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((argc < 3) || (myoptind + 1) >= argc) {
|
||||||
|
print_usage();
|
||||||
|
PX4_ERR("Not enough arguments.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
const char *requested_failure_unit = argv[myoptind];
|
const char *requested_failure_unit = argv[myoptind];
|
||||||
|
|
||||||
for (const auto &failure_unit : failure_units) {
|
for (const auto &failure_unit : failure_units) {
|
||||||
|
|||||||
Reference in New Issue
Block a user