]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
play: Always check arg count and init keymap.
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 14 Jan 2018 21:12:32 +0000 (22:12 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 14 Jan 2018 21:23:22 +0000 (22:23 +0100)
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

diff --git a/play.c b/play.c
index b304e427183d264b09d38eabbc0ec6c77990dec3..bd94fcd9dedb8481185b79320919bce7ede63c70 100644 (file)
--- 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;
                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);
        }
        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);
        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;
        ret = lls(lls_check_arg_count(play_lpr, 1, INT_MAX, &errctx));
        if (ret < 0)
                goto free_cf;