mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 18:47:21 +08:00
pxh: do not use variable sized array on the stack
This is a compiler-specific extension
This commit is contained in:
@@ -101,7 +101,7 @@ int Pxh::process_line(const std::string &line, bool silently_fail)
|
|||||||
|
|
||||||
// Note that argv[argc] always needs to be a nullptr.
|
// Note that argv[argc] always needs to be a nullptr.
|
||||||
// Therefore add one more entry.
|
// Therefore add one more entry.
|
||||||
const char *arg[words.size() + 1];
|
char **arg = new char *[words.size() + 1];
|
||||||
|
|
||||||
for (unsigned i = 0; i < words.size(); ++i) {
|
for (unsigned i = 0; i < words.size(); ++i) {
|
||||||
arg[i] = (char *)words[i].c_str();
|
arg[i] = (char *)words[i].c_str();
|
||||||
@@ -110,7 +110,7 @@ int Pxh::process_line(const std::string &line, bool silently_fail)
|
|||||||
// Explicitly set this nullptr.
|
// Explicitly set this nullptr.
|
||||||
arg[words.size()] = nullptr;
|
arg[words.size()] = nullptr;
|
||||||
|
|
||||||
int retval = _apps[command](words.size(), (char **)arg);
|
int retval = _apps[command](words.size(), arg);
|
||||||
|
|
||||||
if (retval) {
|
if (retval) {
|
||||||
if (!silently_fail) {
|
if (!silently_fail) {
|
||||||
@@ -118,6 +118,8 @@ int Pxh::process_line(const std::string &line, bool silently_fail)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete[] arg;
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
} else if (command == "help") {
|
} else if (command == "help") {
|
||||||
|
|||||||
Reference in New Issue
Block a user