From 658fffb931fba561b521c0fb04f13cd92c4d1c92 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Mon, 7 Sep 2020 10:19:38 +0200 Subject: [PATCH] mem leak in yang filename function --- lib/src/clixon_yang_parse_lib.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/clixon_yang_parse_lib.c b/lib/src/clixon_yang_parse_lib.c index abc8c8f8..640f7c32 100644 --- a/lib/src/clixon_yang_parse_lib.c +++ b/lib/src/clixon_yang_parse_lib.c @@ -1298,8 +1298,11 @@ yang_spec_load_dir(clicon_handle h, char *nextbase = NULL; /* XXX suboptimal algorithm, could combione old/next/base */ if (filename2revision(dp[i+1].d_name, &nextbase, NULL) < 0) goto done; - if (nextbase && strcmp(base, nextbase) == 0) + if (nextbase && strcmp(base, nextbase) == 0){ + free(nextbase); + nextbase = NULL; continue; /* same base: skip; */ + } if (nextbase) free(nextbase); }