From: Peng Fan Date: Fri, 27 Nov 2015 02:12:02 +0000 (+0800) Subject: common: cli_hush: avoid memory leak X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=c6bb23c819b5dcbc5c3491673f5e408c0b9c38b3;p=project%2Fbcm63xx%2Fu-boot.git common: cli_hush: avoid memory leak Need to free memory avoid memory leak, when error. Signed-off-by: Peng Fan Reviewed-by: Simon Glass Cc: Simon Glass Cc: Tom Rini --- diff --git a/common/cli_hush.c b/common/cli_hush.c index f075459911..7f69c062a7 100644 --- a/common/cli_hush.c +++ b/common/cli_hush.c @@ -2471,11 +2471,16 @@ static int done_word(o_string *dest, struct p_context *ctx) } argc = ++child->argc; child->argv = realloc(child->argv, (argc+1)*sizeof(*child->argv)); - if (child->argv == NULL) return 1; + if (child->argv == NULL) { + free(str); + return 1; + } child->argv_nonnull = realloc(child->argv_nonnull, (argc+1)*sizeof(*child->argv_nonnull)); - if (child->argv_nonnull == NULL) + if (child->argv_nonnull == NULL) { + free(str); return 1; + } child->argv[argc-1]=str; child->argv_nonnull[argc-1] = dest->nonnull; child->argv[argc]=NULL;