[binutils-gdb] ldelf_search_needed leak

Alan Modra amodra@sourceware.org
Thu Jan 16 22:08:18 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fc15dc69aed4e9e3f849d02f118d2e236ac935cf

commit fc15dc69aed4e9e3f849d02f118d2e236ac935cf
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Jan 11 16:12:42 2025 +1030

    ldelf_search_needed leak
    
            * ldelf.c (ldelf_search_needed): Free filename before returning.

Diff:
---
 ld/ldelf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ld/ldelf.c b/ld/ldelf.c
index dfe8032f255..ce080585929 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -615,7 +615,10 @@ ldelf_search_needed (const char *path, struct dt_needed *n, int force,
       needed.name = filename;
 
       if (ldelf_try_needed (&needed, force, is_linux))
-	return true;
+	{
+	  free (filename);
+	  return true;
+	}
 
       free (filename);


More information about the Binutils-cvs mailing list