1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-12 02:59:08 +00:00

Fix execi scanning segfault due to bad free. (#693)

This should resolve #690.
This commit is contained in:
Brenden Matthews 2018-12-05 16:21:04 -05:00 committed by GitHub
parent 2a0d2a741a
commit bc0ec94c10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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