From 684315535759e575d1352ec050f56eed4eef1f37 Mon Sep 17 00:00:00 2001 From: ChristophTobler Date: Mon, 2 Oct 2017 16:03:59 +0200 Subject: [PATCH] gpssim: fix seg fault if not enough arguments happens with e.g. 'gpssim -f' --- src/platforms/posix/drivers/gpssim/gpssim.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/platforms/posix/drivers/gpssim/gpssim.cpp b/src/platforms/posix/drivers/gpssim/gpssim.cpp index 7fb69417cc..e728417a69 100644 --- a/src/platforms/posix/drivers/gpssim/gpssim.cpp +++ b/src/platforms/posix/drivers/gpssim/gpssim.cpp @@ -558,11 +558,6 @@ usage(const char *reason) int gpssim_main(int argc, char *argv[]) { - if (argc < 2) { - gpssim::usage("not enough arguments supplied"); - return 1; - } - // set to default const char *device_name = GPS_DEFAULT_UART_PORT; bool fake_gps = false; @@ -595,6 +590,11 @@ gpssim_main(int argc, char *argv[]) } } + if (myoptind >= argc) { + gpssim::usage("not enough arguments supplied"); + return 1; + } + /* * Start/load the driver. */