Skip to contentSkip to conversation

libtraceevent: Fix memleak in make_bprint_args()

PATCH New Steven Rostedt 1 participant 1 message Jun 17, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtraceevent: Fix memleak in make_bprint_args()

From: Wang ShaoBo <[email protected]>

Release arg allocated from alloc_arg() when strdup failed in make_bprint_args().

Fixes 8b43424c32702 ("tools lib traceevent: Remove some die() calls")
---
 src/event-parse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/event-parse.c +3 -1
index 1ba2a78d20a9..4bbf29727e9f 100644
@@ -4915,8 +4915,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;
Signature · 1 line
2.35.1