From 0dd16b472c649936b885838796ab33b351b5695e Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Fri, 8 Jul 2022 10:50:00 -0600 Subject: [PATCH] tools/cgxget: fix a resource leak get_cv_value() Fix a resource leak in get_cv_value(), reported by Coverity tool: CID 258291 (#1 of 1): Resource leak (RESOURCE_LEAK). leaked_storage: Variable handle going out of scope leaks the storage it points to. failure on the realloc(), doesn't free the *handle. Fix it by using the goto read_end(), that does the job of freeing the handle. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- src/tools/cgxget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cgxget.c b/src/tools/cgxget.c index 9cc75d32..418b7496 100644 --- a/src/tools/cgxget.c +++ b/src/tools/cgxget.c @@ -560,7 +560,7 @@ static int get_cv_value(struct control_value * const cv, tmp = realloc(cv->multiline_value, sizeof(char) * (strlen(cv->multiline_value) + strlen(tmp_line) + 3)); if (tmp == NULL) - goto end; + goto read_end; cv->multiline_value = tmp; strcat(cv->multiline_value, "\n\t"); -- 2.47.2