From 7caf21aac8ba2ab3e0b8a004310d424064486607 Mon Sep 17 00:00:00 2001 From: Dale Hamel Date: Wed, 17 Apr 2019 22:21:54 -0400 Subject: [PATCH] Free local string variable on error path when parsing elf notes from memfd-backed file --- src/cc/bcc_proc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/bcc_proc.c b/src/cc/bcc_proc.c index af91d8f099cd..6ce63de89d19 100644 --- a/src/cc/bcc_proc.c +++ b/src/cc/bcc_proc.c @@ -99,8 +99,10 @@ static char *_procutils_memfd_path(const int pid, const uint64_t inum) { strcpy(dirstr, path_buffer); dirstream = opendir(dirstr); - if (dirstream == NULL) + if (dirstream == NULL) { + free(dirstr); return NULL; + } while (path == NULL && (dent = readdir(dirstream)) != NULL) { snprintf(path_buffer, (PATH_MAX + 1), "%s/%s", dirstr, dent->d_name);