From cc210cce03c6e9bd4473159dc8cbcc95f24bfba4 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 14 Jan 2018 22:12:32 +0100 Subject: [PATCH] play: Always check arg count and init keymap. Currently we miss to do so if the config file does not exist or is empty. This triggers the following assertion if, in addition, no non-option arguments given: para_play: string.c:62: para_malloc: Assertion `size' failed. This is because we try to allocate a zero sized buffer in main() due to lls_num_inputs() returning 0. Fix this by changing the target of the goto in handle_help_flags(). This bug was introduced during the conversion to lopsub. --- play.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/play.c b/play.c index b304e427..bd94fcd9 100644 --- a/play.c +++ b/play.c @@ -178,7 +178,7 @@ static void parse_config_or_die(int argc, char *argv[]) if (ret == -ERRNO_TO_PARA_ERROR(ENOENT) && OPT_GIVEN(CONFIG_FILE)) goto free_cf; ret = 0; - goto free_cf; + goto check_arg_count; } ret = lls(lls_convert_config(map, sz, NULL, &cf_argv, &errctx)); para_munmap(map, sz); @@ -196,7 +196,7 @@ static void parse_config_or_die(int argc, char *argv[]) lls_free_parse_result(play_lpr, cmd); play_lpr = merged_lpr; loglevel = OPT_UINT32_VAL(LOGLEVEL); - +check_arg_count: ret = lls(lls_check_arg_count(play_lpr, 1, INT_MAX, &errctx)); if (ret < 0) goto free_cf; -- 2.30.2