[PATCH] elflint: Fix memory leak in check_gnu_hash function

Maks Mishin maks.mishinfz@gmail.com
Wed Sep 18 08:58:07 GMT 2024


Dynamic memory, referenced by 'collected', is allocated at elflint.c:2235
and lost at elflint.c:2296.

Found by RASU JSC with SVACE.

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
 src/elflint.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/elflint.c b/src/elflint.c
index e56e1465..cdc6108d 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -2293,6 +2293,7 @@ section [%2d] '%s': hash value for symbol %u in chain for bucket %zu wrong\n"),
 section [%2d] '%s': mask index for symbol %u in chain for bucket %zu wrong\n"),
 			     idx, section_name (ebl, idx), symidx,
 			     cnt - (4 + bitmask_words));
+		      free (collected.p32);
 		      return;
 		    }
 		  if (classbits == 32)
-- 
2.34.1



More information about the Elfutils-devel mailing list