From 06c229dfd4357b6bb789545c1a92be232cce7406 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 21 May 2019 11:34:50 +1000 Subject: [PATCH] [common] option: fix invalid access of null/invalid options --- VERSION | 2 +- common/src/option.c | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/VERSION b/VERSION index 52167491..f63c68bf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -a12-192-gb9841351b4+1 \ No newline at end of file +a12-193-g2d5f6d65ce+1 \ No newline at end of file diff --git a/common/src/option.c b/common/src/option.c index eec393fb..f3ec8d7f 100644 --- a/common/src/option.c +++ b/common/src/option.c @@ -267,15 +267,14 @@ bool option_parse(int argc, char * argv[]) if (state.options[i]->shortopt == argv[a][1]) { o = state.options[i]; + if (o->type != OPTION_TYPE_BOOL && a < argc - 1) + { + ++a; + value = strdup(argv[a]); + } break; } } - - if (o->type != OPTION_TYPE_BOOL && a < argc - 1) - { - ++a; - value = strdup(argv[a]); - } } else {