From 7064b73b483891b4a73e78c59cddcc25f3cbef35 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 2 Jun 2020 13:27:54 +0200 Subject: [PATCH] chg parsing free Thanks @doegox! --- client/deps/cliparser/cliparser.c | 7 ++----- client/deps/cliparser/cliparser.h | 9 +++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/client/deps/cliparser/cliparser.c b/client/deps/cliparser/cliparser.c index b3beb6ae0..25cd786d7 100644 --- a/client/deps/cliparser/cliparser.c +++ b/client/deps/cliparser/cliparser.c @@ -146,11 +146,8 @@ int CLIParserParseStringEx(CLIParserContext *ctx, const char *str, void *vargtab } void CLIParserFree(CLIParserContext *ctx) { - if (ctx != NULL) { - arg_freetable(ctx->argtable, ctx->argtableLen); - free(ctx); - ctx = NULL; - } + arg_freetable(ctx->argtable, ctx->argtableLen); + free(ctx); } // convertors diff --git a/client/deps/cliparser/cliparser.h b/client/deps/cliparser/cliparser.h index 0bb75413f..b88acefc5 100644 --- a/client/deps/cliparser/cliparser.h +++ b/client/deps/cliparser/cliparser.h @@ -27,10 +27,11 @@ #define arg_strx1(shortopts, longopts, datatype, glossary) (arg_strn((shortopts), (longopts), (datatype), 1, 250, (glossary))) #define arg_strx0(shortopts, longopts, datatype, glossary) (arg_strn((shortopts), (longopts), (datatype), 0, 250, (glossary))) -#define CLIExecWithReturn(ctx, cmd, atbl, ifempty) if (CLIParserParseString(ctx, cmd, atbl, arg_getsize(atbl), ifempty)){CLIParserFree(ctx);return PM3_ESOFT;} -#define CLIGetHexBLessWithReturn(ctx, paramnum, data, datalen, delta) if (CLIParamHexToBuf(arg_get_str(paramnum), data, sizeof(data) - (delta), datalen)) {CLIParserFree(ctx);return PM3_ESOFT;} -#define CLIGetHexWithReturn(ctx, paramnum, data, datalen) if (CLIParamHexToBuf(arg_get_str(paramnum), data, sizeof(data), datalen)) {CLIParserFree(ctx);return PM3_ESOFT;} -#define CLIGetStrWithReturn(ctx, paramnum, data, datalen) if (CLIParamStrToBuf(arg_get_str(paramnum), data, sizeof(data), datalen)) {CLIParserFree(ctx);return PM3_ESOFT;} +#define CLIFree(ctx) if ((ctx)) {CLIParserFree((ctx)); (ctx)=NULL;} +#define CLIExecWithReturn(ctx, cmd, atbl, ifempty) if (CLIParserParseString(ctx, cmd, atbl, arg_getsize(atbl), ifempty)){if ((ctx)) CLIParserFree((ctx)); (ctx)=NULL;return PM3_ESOFT;} +#define CLIGetHexBLessWithReturn(ctx, paramnum, data, datalen, delta) if (CLIParamHexToBuf(arg_get_str(paramnum), data, sizeof(data) - (delta), datalen)) {if ((ctx)) CLIParserFree((ctx)); (ctx)=NULL;return PM3_ESOFT;} +#define CLIGetHexWithReturn(ctx, paramnum, data, datalen) if (CLIParamHexToBuf(arg_get_str(paramnum), data, sizeof(data), datalen)) {if ((ctx)) CLIParserFree((ctx)); (ctx)=NULL;return PM3_ESOFT;} +#define CLIGetStrWithReturn(ctx, paramnum, data, datalen) if (CLIParamStrToBuf(arg_get_str(paramnum), data, sizeof(data), datalen)) {if ((ctx)) CLIParserFree((ctx)); (ctx)=NULL;return PM3_ESOFT;} typedef struct { void **argtable;