From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org
Subject: [committed] Fix memory leak in build_abbrevs
Date: Wed, 24 Mar 2021 18:06:43 +0100 [thread overview]
Message-ID: <20210324170642.GA2685@delia> (raw)
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;
reply other threads:[~2021-03-24 17:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210324170642.GA2685@delia \
--to=tdevries@suse.de \
--cc=dwz@sourceware.org \
--cc=jakub@redhat.com \
--cc=mark@klomp.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).