* [committed] Fix memory leak in build_abbrevs
@ 2021-03-24 17:06 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2021-03-24 17:06 UTC (permalink / raw)
To: dwz, jakub, mark
Hi,
I noticed that build_abbrevs leaks h in case the "return 1" path is taken:
...
htab_t h = htab_try_create (50, abbrev_hash, abbrev_eq2, NULL);
if (h == NULL)
dwz_oom ();
if (build_abbrevs_for_die (h, cu, cu->cu_die, NULL, NULL, t, ndies, vec,
false))
return 1;
...
Fix this by calling htab_delete before returning 1.
Committed to trunk.
Thanks,
- Tom
Fix memory leak in build_abbrevs
2021-03-24 Tom de Vries <tdevries@suse.de>
* dwz.c (build_abbrevs): Clean up in case of return 1.
---
dwz.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dwz.c b/dwz.c
index b212d6d..436bae1 100644
--- a/dwz.c
+++ b/dwz.c
@@ -11234,7 +11234,10 @@ build_abbrevs (dw_cu_ref cu, struct abbrev_tag *t, unsigned int *ndies,
if (build_abbrevs_for_die (h, cu, cu->cu_die, NULL, NULL, t, ndies, vec,
false))
- return 1;
+ {
+ htab_delete (h);
+ return 1;
+ }
cu->cu_new_abbrev = h;
return 0;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-24 17:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 17:06 [committed] Fix memory leak in build_abbrevs Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).