mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user