mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-12 11:04:10 +00:00
Fix execi scanning segfault due to bad free. (#693)
This should resolve #690.
This commit is contained in:
parent
2a0d2a741a
commit
bc0ec94c10
@ -245,8 +245,8 @@ void fill_p(const char *buffer, struct text_object *obj, char *p,
|
||||
void scan_exec_arg(struct text_object *obj, const char *arg,
|
||||
unsigned int execflag) {
|
||||
const char *cmd = arg;
|
||||
char *orig_cmd = nullptr;
|
||||
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) {
|
||||
@ -263,7 +263,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;
|
||||
orig_cmd = (char *)cmd;
|
||||
}
|
||||
|
||||
/* parse any special options for the graphical exec types */
|
||||
@ -289,9 +289,7 @@ 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);
|
||||
}
|
||||
free_and_zero(orig_cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user