From 2b85c594b34052e50f861f9329796f40b7c96876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 15 Jun 2016 09:53:37 +0200 Subject: [PATCH] fix px4_getopt: correctly handle options that take an argument, but no argument is given This lead to a segfault, for example 'logger start -r' --- src/platforms/common/px4_getopt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/platforms/common/px4_getopt.c b/src/platforms/common/px4_getopt.c index 863b5816b4..a242e66e83 100644 --- a/src/platforms/common/px4_getopt.c +++ b/src/platforms/common/px4_getopt.c @@ -165,6 +165,9 @@ __EXPORT int px4_getopt(int argc, char *argv[], const char *options, int *myopti if (takesarg) { *myoptarg = argv[*myoptind]; + if (!*myoptarg) { //Error: option takes an argument, but there is no more argument + return -1; + } *myoptind += 1; }