From fd2ded08e4110ce0745f5bf71e8699cb8bee2911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 16 Jun 2025 15:47:05 +0200 Subject: [PATCH] pxh: do not use variable sized array on the stack This is a compiler-specific extension --- platforms/posix/src/px4/common/px4_daemon/pxh.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platforms/posix/src/px4/common/px4_daemon/pxh.cpp b/platforms/posix/src/px4/common/px4_daemon/pxh.cpp index 9bcf0268ad..8774facd71 100644 --- a/platforms/posix/src/px4/common/px4_daemon/pxh.cpp +++ b/platforms/posix/src/px4/common/px4_daemon/pxh.cpp @@ -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. // 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) { 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. arg[words.size()] = nullptr; - int retval = _apps[command](words.size(), (char **)arg); + int retval = _apps[command](words.size(), arg); if (retval) { if (!silently_fail) { @@ -118,6 +118,8 @@ int Pxh::process_line(const std::string &line, bool silently_fail) } } + delete[] arg; + return retval; } else if (command == "help") {