mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-02-11 16:38:55 +00:00
exec.cc: Free malloced pointer after use in scan_exec_arg() (#607)
This commit is contained in:
parent
fcbc5c8ba2
commit
bbaa0e9ac8
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user