From 009fc43bee3781347ef188d71e12a12cd0a9ca9f Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Wed, 20 Jul 2022 03:12:32 +0200 Subject: [PATCH] deps/opts-parser: Skip parsing of empty strings --- deps/opts-parser/opts-parser.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/deps/opts-parser/opts-parser.c b/deps/opts-parser/opts-parser.c index 1e3f3d225..5183fdcd5 100644 --- a/deps/opts-parser/opts-parser.c +++ b/deps/opts-parser/opts-parser.c @@ -24,16 +24,13 @@ static bool getparam(const char *param, char **name, const char **value) struct obs_options obs_parse_options(const char *options_string) { + if (!options_string || !*options_string) + goto failure; + char **input_words = strlist_split(options_string, ' ', false); - if (!input_words) { - return (struct obs_options){ - .count = 0, - .options = NULL, - .ignored_word_count = 0, - .ignored_words = NULL, - .input_words = NULL, - }; - } + if (!input_words) + goto failure; + size_t input_option_count = 0; for (char **input_word = input_words; *input_word; ++input_word) input_option_count += 1; @@ -59,6 +56,15 @@ struct obs_options obs_parse_options(const char *options_string) .ignored_words = ignored_words, .input_words = input_words, }; + +failure: + return (struct obs_options){ + .count = 0, + .options = NULL, + .ignored_word_count = 0, + .ignored_words = NULL, + .input_words = NULL, + }; } void obs_free_options(struct obs_options options)