Skip to content

Commit

Permalink
Merge pull request iovisor#2320 from dalehamel/fix-memfd-memleak-dirstr
Browse files Browse the repository at this point in the history
Fix possible memory leak in error path when elf notes are backed by a memfd path
  • Loading branch information
palmtenor committed Apr 19, 2019
2 parents c36f5bf + 7caf21a commit 440268e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cc/bcc_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 440268e

Please sign in to comment.