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'
This commit is contained in:
Beat Küng
2016-06-15 09:53:37 +02:00
parent d66af65a92
commit 2b85c594b3

View File

@@ -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;
}