From: Andre Noll Date: Sun, 13 Jan 2019 20:01:14 +0000 (+0100) Subject: lls_parse_arg(): Don't free static memory. X-Git-Tag: v1.0.2~6 X-Git-Url: http://git.tuebingen.mpg.de/?p=lopsub.git;a=commitdiff_plain;h=cd0ae8bc3fd6cd643ef67f068a00d7f91927b0ea;hp=1c567dc36fd0d378906a609683e141dc515df750 lls_parse_arg(): Don't free static memory. If opt->values is not NULL, no string value is stored on the heap, and the current code results is a segmentation fault. --- diff --git a/lopsub.c b/lopsub.c index 55ea6ac..44abc93 100644 --- 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);