From e58607e1432789ccfe2c7e91dcb2ae88115fd795 Mon Sep 17 00:00:00 2001 From: bluew Date: Sun, 17 Mar 2024 18:35:34 +0100 Subject: [PATCH 1/2] src: Fix memory leak of privately allocated data in riscv-dis --- src/trace_debugger.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/trace_debugger.c b/src/trace_debugger.c index 0cd80f9..ede3e9e 100644 --- a/src/trace_debugger.c +++ b/src/trace_debugger.c @@ -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. */ @@ -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; } From 9107667cdf8e1fec2c3a2f2f7ee9bcecec03dd6f Mon Sep 17 00:00:00 2001 From: bluew Date: Sun, 17 Mar 2024 18:36:44 +0100 Subject: [PATCH 2/2] gitignore: Ignore doc, backup files and clangd caches --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 7ade25b..90f3cdf 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,8 @@ libtrdb.a tests trdb benchmarks +doc/html +doc/latex .Tpo @@ -62,4 +64,7 @@ m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 +*~ +.cache + Makefile