diff --git a/src/platforms/common/px4_getopt.c b/src/platforms/common/px4_getopt.c index 6b0427b936..d446a1fadc 100644 --- a/src/platforms/common/px4_getopt.c +++ b/src/platforms/common/px4_getopt.c @@ -168,9 +168,11 @@ __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; }