From 7656ed0e011f910b84131360cc82e335f01913db Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 14 Mar 2024 15:45:50 -0400 Subject: Allow path_store function to replace existing path elements without causing memory leaks --- src/utils.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index d1f3f8f..62bf58a 100644 --- a/src/utils.c +++ b/src/utils.c @@ -517,6 +517,10 @@ int path_store(char **destptr, size_t maxlen, const char *base, const char *path goto l_path_setup_error; } + if (*destptr) { + guard_free(*destptr); + } + (*destptr) = realpath(path_tmp, NULL); if (!*destptr) { goto l_path_setup_error; -- cgit