The following variable is not freed in this scan_exec_arg() function:
https://github.com/brndnmtthws/conky/blob/3d5e152a8b264c96f40237a767a9051435dbf8d2/src/exec.cc#L263
diff --git a/src/exec.cc b/src/exec.cc
index 9ba47408..bc6bf47b 100644
--- a/src/exec.cc
+++ b/src/exec.cc
@@ -245,6 +245,7 @@ void scan_exec_arg(struct text_object *obj, const char *arg,
unsigned int execflag) {
const char *cmd = arg;
struct execi_data *ed;
+ unsigned int free_cmd = 0;
/* in case we have an execi object, we need to parse out the interval */
if ((execflag & EF_EXECI) != 0u) {
@@ -261,6 +262,7 @@ void scan_exec_arg(struct text_object *obj, const char *arg,
/* set cmd to everything after the interval */
cmd = strndup(arg + n, text_buffer_size.get(*state));
+ free_cmd = 1;
}
/* parse any special options for the graphical exec types */
@@ -286,6 +288,9 @@ void scan_exec_arg(struct text_object *obj, const char *arg,
ed->cmd = strndup(cmd != nullptr ? cmd : "", text_buffer_size.get(*state));
obj->data.opaque = ed;
}
+ if (cmd != nullptr && 1 == free_cmd) {
+ free((char *)cmd);
+ }
}
/**
@lasers Can you open up a PR with this patch ?
Give me commit description. exec.cc: free willy the variable ?
exec.cc: Free malloced pointer after use in scan_exec_arg()
Most helpful comment
Closed via https://github.com/brndnmtthws/conky/pull/607