mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-02-12 00:48:49 +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) {
|
unsigned int execflag) {
|
||||||
const char *cmd = arg;
|
const char *cmd = arg;
|
||||||
struct execi_data *ed;
|
struct execi_data *ed;
|
||||||
|
unsigned int free_cmd = 0;
|
||||||
|
|
||||||
/* in case we have an execi object, we need to parse out the interval */
|
/* in case we have an execi object, we need to parse out the interval */
|
||||||
if ((execflag & EF_EXECI) != 0u) {
|
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 */
|
/* set cmd to everything after the interval */
|
||||||
cmd = strndup(arg + n, text_buffer_size.get(*state));
|
cmd = strndup(arg + n, text_buffer_size.get(*state));
|
||||||
|
free_cmd = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse any special options for the graphical exec types */
|
/* 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));
|
ed->cmd = strndup(cmd != nullptr ? cmd : "", text_buffer_size.get(*state));
|
||||||
obj->data.opaque = ed;
|
obj->data.opaque = ed;
|
||||||
}
|
}
|
||||||
|
if (cmd != nullptr && 1 == free_cmd) {
|
||||||
|
free((char *)cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user