1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-08-31 16:22:36 +02:00

common: cli_hush: avoid memory leak

Need to free memory avoid memory leak, when error.

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
This commit is contained in:
Peng Fan
2015-11-27 10:12:02 +08:00
committed by Tom Rini
parent 63ce348d27
commit c6bb23c819

View File

@@ -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;