diff options
author | Andre Hartmann <aha_1980@gmx.de> | 2019-09-22 10:13:01 +0200 |
---|---|---|
committer | Andre Hartmann <aha_1980@gmx.de> | 2019-09-23 10:27:22 +0200 |
commit | cdd7b51340b9bc60a8b2cd13259b0a293588116e (patch) | |
tree | c2a34cfee8eb8cf5a6ede2219e94e04ad7495aa7 /src | |
parent | be05a82406c2b82d0b2bc0aa4866df31a46c2352 (diff) |
CanBusUtil: Fix crash on listening without arguments
The listening option expects two parameters:
plugin and device.
But it was possible to call the program without
or with only one parameter, which lead to a crash
in util.start(args.at(0), args.at(1), data).
Fix that by always checking the argument size first.
Change-Id: I7c49bfc875f99286e1f04d1d4ef23b7971577363
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/canbusutil/main.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/tools/canbusutil/main.cpp b/src/tools/canbusutil/main.cpp index 1277325..cbb7d7f 100644 --- a/src/tools/canbusutil/main.cpp +++ b/src/tools/canbusutil/main.cpp @@ -155,7 +155,9 @@ int main(int argc, char *argv[]) data = args.at(2); } else if (args.size() == 1 && parser.isSet(listDevicesOption)) { return util.printDevices(args.at(0)); - } else if (args.size() != 2) { + } + + if (args.size() < 2 || args.size() > 3) { output << CanBusUtil::tr("Invalid number of arguments (%1 given).").arg(args.size()); output << Qt::endl << Qt::endl << parser.helpText(); return 1; |