aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-04-12 08:51:19 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-04-12 08:51:19 -0400
commite71c2897880025b3a67b29ec141aeec4d3065ded (patch)
tree3c13367cc9ac99439b19ba871c073d40ce178ca5
parentc4bd4f2d70128c10418650b370843baf1314d4e9 (diff)
downloadstasis-e71c2897880025b3a67b29ec141aeec4d3065ded.tar.gz
conv_{str,str_noexpand}() attempt to free the destination before writing data
* Avoids memory leaks when updating destination with a repeated call
-rw-r--r--src/deliverable.c6
1 files changed, 6 insertions, 0 deletions
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);
}