Re: [PATCH] fix double free issue in event_read_print_args
Totoro W <[email protected]>
| Newsgroups | org.kernel.vger.linux-trace-devel |
|---|---|
| Message-ID | <CAFrM9zvV9oHvCpVmt3un-wMFJFoyXq7SOWTOENpDGrn_HQQDDQ@mail.gmail.com> |
Oops, missing the patch part, here it is:
diff --git a/src/event-parse.c b/src/event-parse.c
index 9f0522c..1f51ee9 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -2375,8 +2375,6 @@ process_op(struct tep_event *event, struct
tep_print_arg *arg, char **tok)
/* it will set arg->op.right */
type = process_cond(event, arg, tok);
- if (type == TEP_EVENT_ERROR)
- free(token);
} else if (strcmp(token, ">>") == 0 ||
strcmp(token, "<<") == 0 ||
@@ -3787,7 +3785,7 @@ static int event_read_print_args(struct
tep_event *event, struct tep_print_arg *
{
enum tep_event_type type = TEP_EVENT_ERROR;
struct tep_print_arg *arg;
- char *token;
+ char *token = NULL;
int args = 0;
do {
@@ -3817,6 +3815,7 @@ static int event_read_print_args(struct
tep_event *event, struct tep_print_arg *
if (type == TEP_EVENT_OP) {
type = process_op(event, arg, &token);
free_token(token);
+ token = NULL;
if (consolidate_op_arg(arg) < 0)
type = TEP_EVENT_ERROR;