From f479f4618923ca497d499dcaa533d19a2403e0b5 Mon Sep 17 00:00:00 2001 From: Sunny Kumar Date: Tue, 4 Dec 2018 00:18:42 +0530 Subject: cli: fix memory leak in cli-cmd-system.c This patch fixes memory leak reported by ASan. SUMMARY: AddressSanitizer: 384 byte(s) leaked in 2 allocation(s). updates: bz#1633930 Change-Id: I93ebddcfeea3d51547e00775db2c9d99f5dfafea Signed-off-by: Sunny Kumar --- cli/src/cli-cmd-system.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cli/src/cli-cmd-system.c b/cli/src/cli-cmd-system.c index 46ff926a2b8..8cd15424572 100644 --- a/cli/src/cli-cmd-system.c +++ b/cli/src/cli-cmd-system.c @@ -67,12 +67,13 @@ cli_cmd_getspec_cbk(struct cli_state *state, struct cli_cmd_word *word, out: if (!proc && ret) { - if (dict) - dict_unref(dict); if (wordcount > 1) cli_out("Fetching spec for volume %s failed", (char *)words[2]); } + if (dict) + dict_unref(dict); + return ret; } @@ -109,12 +110,12 @@ cli_cmd_pmap_b2p_cbk(struct cli_state *state, struct cli_cmd_word *word, out: if (!proc && ret) { - if (dict) - dict_unref(dict); if (wordcount > 1) cli_out("Fetching spec for volume %s failed", (char *)words[3]); } + if (dict) + dict_unref(dict); return ret; } @@ -322,6 +323,9 @@ out: cli_out("uuid get failed"); } + if (dict) + dict_unref(dict); + CLI_STACK_DESTROY(frame); return ret; } @@ -383,6 +387,9 @@ out: cli_out("uuid reset failed"); } + if (dict) + dict_unref(dict); + CLI_STACK_DESTROY(frame); return ret; -- cgit