X-Git-Url: http://git.tuebingen.mpg.de/?p=lopsub.git;a=blobdiff_plain;f=lopsub.c;h=44abc93348c7b6e4120caeeea620c0f6504d46bb;hp=2ba26213c9c803f398208812b4069ea24321a3d4;hb=51ae45300475de90d323cfa92b2bd42422201d27;hpb=9d3fd447f36e1a144a40037d559a92562d120703 diff --git a/lopsub.c b/lopsub.c index 2ba2621..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); @@ -1296,6 +1296,7 @@ int lls_deserialize_parse_result(const char *buf, const struct lls_command *cmd, if (!lor->value[j].string_val) { for (; j >= 0; j--) free(lor->value[j].string_val); + free(lor->value); goto free_options; } p += strlen(lor->value[j].string_val) + 1; @@ -1313,7 +1314,7 @@ int lls_deserialize_parse_result(const char *buf, const struct lls_command *cmd, *lprp = lpr; return 1; free_options: - for (; i >= 0; i--) { + for (i--; i >= 0; i--) { const struct lls_option *opt = cmd->options + i; struct lls_opt_result *lor = lpr->opt_result + i; unsigned num_vals = (opt->flags & LLS_MULTIPLE)? lor->given : 1;