Skip to content

Commit

Permalink
Merge pull request #17 from pulp-platform/leak
Browse files Browse the repository at this point in the history
Fix memory leak
  • Loading branch information
bluewww authored Mar 17, 2024
2 parents 9de29fb + 9107667 commit 2cefee8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ libtrdb.a
tests
trdb
benchmarks
doc/html
doc/latex


.Tpo
Expand Down Expand Up @@ -62,4 +64,7 @@ m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4

*~
.cache

Makefile
19 changes: 14 additions & 5 deletions src/trace_debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1318,11 +1318,14 @@ static void free_section_for_debugging(struct disassemble_info *dinfo)
{
if (!dinfo)
return;
free(dinfo->buffer);
dinfo->buffer = NULL;
dinfo->buffer_vma = 0;
dinfo->buffer_length = 0;
dinfo->section = NULL;

if (dinfo->buffer) {
free(dinfo->buffer);
dinfo->buffer = NULL;
dinfo->buffer_vma = 0;
dinfo->buffer_length = 0;
dinfo->section = NULL;
}
}

/* Load the section given by @p section from @p abfd into @p dinfo. */
Expand Down Expand Up @@ -2063,10 +2066,16 @@ int trdb_decompress_trace(struct trdb_ctx *c, bfd *abfd,
}
}
free_section_for_debugging(&dinfo);
if ((&dinfo)->private_data)
free((&dinfo)->private_data);

return status;

fail:
free_section_for_debugging(&dinfo);
if ((&dinfo)->private_data)
free((&dinfo)->private_data);

return status;
}

Expand Down

0 comments on commit 2cefee8

Please sign in to comment.