1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-28 21:19:10 +00:00

exec.cc: Free malloced pointer after use in scan_exec_arg() (#607)

This commit is contained in:
lasers 2018-08-13 13:55:31 -05:00 committed by Brenden Matthews
parent fcbc5c8ba2
commit bbaa0e9ac8

View File

@ -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);
}
}
/**