From b0d38a513c324655d5a7762575a35b82dcf1c808 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 27 Jul 2022 17:40:49 +0200 Subject: [PATCH] Memory leak in cli load_config_file --- apps/cli/cli_common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/cli/cli_common.c b/apps/cli/cli_common.c index cb34e4f8..59967fd0 100644 --- a/apps/cli/cli_common.c +++ b/apps/cli/cli_common.c @@ -828,7 +828,7 @@ load_config_file(clicon_handle h, FILE *fp = NULL; cxobj *xt = NULL; cxobj *x; - cbuf *cbxml; + cbuf *cbxml = NULL; char *formatstr = NULL; enum format_enum format = FORMAT_XML; yang_stmt *yspec; @@ -952,10 +952,11 @@ load_config_file(clicon_handle h, replace?OP_REPLACE:OP_MERGE, cbuf_get(cbxml)) < 0) goto done; - cbuf_free(cbxml); ok: ret = 0; done: + if (cbxml) + cbuf_free(cbxml); if (lineptr) free(lineptr); if (xerr)