]> git.tuebingen.mpg.de Git - lopsub.git/commitdiff
lls_parse_arg(): Don't free static memory.
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 13 Jan 2019 20:01:14 +0000 (21:01 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 5 Mar 2019 10:06:31 +0000 (11:06 +0100)
If opt->values is not NULL, no string value is stored on the heap,
and the current code results is a segmentation fault.

lopsub.c

index 55ea6ac56253e0705e551780271acb9be859ea25..44abc93348c7b6e4120caeeea620c0f6504d46bb 100644 (file)
--- a/lopsub.c
+++ b/lopsub.c
@@ -651,7 +651,7 @@ static int lls_parse_arg(struct lls_arg *la, const struct lls_option *opts,
        }
        switch (opt->arg_type) {
        case LLS_STRING:
-               if (lor->given > 0 && !multiple)
+               if (!opt->values && lor->given > 0 && !multiple)
                        free(lor->value[idx].string_val);
                if (opt->values) {
                        ret = check_enum_arg(la->arg, opt, errctx);