From f58079bc5d29a46fe26c45ff85864e00ccffce23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Fri, 24 May 2019 11:41:43 +0200 Subject: [PATCH] pxh.cpp: fix invalid reference if words is empty This can happen for example if 'line' is a space. --- platforms/posix/src/px4_daemon/pxh.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platforms/posix/src/px4_daemon/pxh.cpp b/platforms/posix/src/px4_daemon/pxh.cpp index 4544878a33..8858934fe6 100644 --- a/platforms/posix/src/px4_daemon/pxh.cpp +++ b/platforms/posix/src/px4_daemon/pxh.cpp @@ -84,6 +84,10 @@ int Pxh::process_line(const std::string &line, bool silently_fail) words.push_back(word); } + if (words.empty()) { + return 0; + } + const std::string &command(words.front()); if (_apps.find(command) != _apps.end()) {