lkml.org 
[lkml]   [2022]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] libtraceevent: fix memleak in make_bprint_args()
Date
Release arg allocated from alloc_arg() when strdup failed in make_bprint_args().

Fixes: a6d2a61ac653 ("tools lib traceevent: Remove some die() calls")
Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
---
tools/lib/traceevent/event-parse.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 8e24c4c78c7f..69e4d5229362 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4507,8 +4507,10 @@ static struct tep_print_arg *make_bprint_args(char *fmt, void *data, int size, s
arg->next = NULL;
arg->type = TEP_PRINT_BSTRING;
arg->string.string = strdup(bptr);
- if (!arg->string.string)
+ if (!arg->string.string) {
+ free(arg);
goto out_free;
+ }
bptr += strlen(bptr) + 1;
*next = arg;
next = &arg->next;
--
2.25.1
\
 
 \ /
  Last update: 2022-05-13 04:23    [W:0.097 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site