]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
readelf memory leaks
authorAlan Modra <amodra@gmail.com>
Wed, 1 Jan 2025 12:22:59 +0000 (22:52 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 1 Jan 2025 12:22:59 +0000 (22:52 +1030)
commit94e2b2a770fc49e42c9baec80f4fb88f63391a4e
treeb6dfb075714ab2e72afd8f18a42e556e2cddab87
parent0e4e9aa0a7727819a0b5b240617f8f4243c4c80f
readelf memory leaks

This fixes multiple readelf memory leaks:
- The check functions used to validate separate debug info files
  opened and read file data but didn't release the memory nor close
  the file.
- A string table was being re-read into a buffer, leaking the old
  contents.
- Decompressed section contents leaked.

* dwarf.c (check_gnu_debuglink): Always call close_debug_file.
(check_gnu_debugaltlink): Likewise.
* readelf.c (process_section_headers): Don't read string_table
again if we already have it.
(maybe_expand_or_relocate_section): Add decomp_buf param to
return new uncompressed buffer.
(dump_section_as_strings, filedata->string_table): Free any
uncompressed buffer.
(process_file): Call close_debug_file rather than freeing
various filedata components.
binutils/dwarf.c
binutils/readelf.c