public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/1] libctf: Fix double free in ctf_link_add_cu_mapping.
@ 2022-12-07 14:11 Felix Willgerodt
  2022-12-08  1:22 ` Alan Modra
  0 siblings, 1 reply; 4+ messages in thread
From: Felix Willgerodt @ 2022-12-07 14:11 UTC (permalink / raw)
  To: binutils; +Cc: Felix Willgerodt

This fixes a potential double free which can occur if we jump to
oom_noerrno after the first free.

I am not very familiar with libctf, so any comments are welcome.
I am wondering if the right solution wouldn't be to free both t and f before
the "return 0".  But I didn't fully understand the code and saw that other
users of ctf_dynhash_insert() also don't free the key manually.

libctf/ChangeLog:
* ctf-link.c (ctf_link_add_cu_mapping): Adjust freeing logic.
---
 libctf/ctf-link.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c
index 702f2b4d5fe..e59e415eb41 100644
--- a/libctf/ctf-link.c
+++ b/libctf/ctf-link.c
@@ -430,8 +430,6 @@ ctf_link_add_cu_mapping (ctf_dict_t *fp, const char *from, const char *to)
 	  goto oom_noerrno;
 	}
     }
-  else
-    free (t);
 
   if (ctf_dynhash_insert (one_out, f, NULL) < 0)
     {
-- 
2.34.3

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-15 15:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07 14:11 [PATCH 1/1] libctf: Fix double free in ctf_link_add_cu_mapping Felix Willgerodt
2022-12-08  1:22 ` Alan Modra
2022-12-08  7:47   ` Willgerodt, Felix
2022-12-15 15:26   ` Nick Alcock

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).