PATCH: Fix memory leak in bfd/elf.c

Cary Coutant ccoutant@google.com
Thu May 1 01:55:00 GMT 2008


This patch fixes a memory leak of sorts in bfd_elf_get_str_section
that happens if the symbol string table is corrupt (e.g., it can't be
read from the file because the file has been truncated). Without the
patch, bfd will attempt to read the whole symbol string table for the
first symbol, fail, set the cached contents to NULL, then try again
for the second symbol, and so on. Each time, space for the string
table is allocated in the bfd structure. It would all get freed
eventually, but not until the bfd is closed. For a file with thousands
of symbols and a huge string table, bfd ends up using enormous amounts
of memory just to do a simple nm.

	* elf.c (bfd_elf_get_str_section): Fix memory leak caused by
	corrupt string table.

i386:

		=== binutils Summary ===

# of expected passes		101
# of expected failures		2

x86_64:

		=== binutils Summary ===

# of expected passes		47
# of expected failures		1

OK to commit?

-cary
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: corrupt-strtab-patch.txt
URL: <https://sourceware.org/pipermail/binutils/attachments/20080501/bb8026a9/attachment.txt>


More information about the Binutils mailing list