From e71c2897880025b3a67b29ec141aeec4d3065ded Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 12 Apr 2024 08:51:19 -0400 Subject: conv_{str,str_noexpand}() attempt to free the destination before writing data * Avoids memory leaks when updating destination with a repeated call --- src/deliverable.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/deliverable.c b/src/deliverable.c index b7dd973..510baa3 100644 --- a/src/deliverable.c +++ b/src/deliverable.c @@ -21,6 +21,9 @@ static void conv_int(int *x, union INIVal val) { } static void conv_str(char **x, union INIVal val) { + if (*x) { + guard_free(*x); + } if (val.as_char_p) { char *tplop = tpl_render(val.as_char_p); if (tplop) { @@ -34,6 +37,9 @@ static void conv_str(char **x, union INIVal val) { } static void conv_str_noexpand(char **x, union INIVal val) { + if (*x) { + guard_free(*x); + } *x = strdup(val.as_char_p); } -- cgit