[U-Boot] [PATCH] common: cli_hush: avoid memory leak
Peng Fan
Peng.Fan at freescale.com
Wed Nov 25 10:16:20 CET 2015
Need to free memory avoid memory leak, when error.
Signed-off-by: Peng Fan <Peng.Fan at freescale.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Tom Rini <trini at konsulko.com>
---
common/cli_hush.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/common/cli_hush.c b/common/cli_hush.c
index f075459..ab85225 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -2474,8 +2474,10 @@ static int done_word(o_string *dest, struct p_context *ctx)
if (child->argv == NULL) 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;
--
2.6.2
More information about the U-Boot
mailing list