From f3bc603561c993cdb8811c361ec5e9e484628cdc Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 24 Sep 2022 18:14:14 +0930 Subject: stab nearest_line bfd_malloc_and_get_section bfd_malloc_and_get_section performs some sanity checks on the section size before allocating memory. This patch avails the stab nearest_line code of that sanity checking, and tidies up memory afterward. * coffgen.c (_bfd_coff_close_and_cleanup): Call _bfd_stab_cleanup. * elf.c (_bfd_elf_close_and_cleanup): Likewise. * syms.c (_bfd_stab_section_find_nearest_line): Set *pinfo earlier. Use bfd_malloc_and_get_section. Free malloc'd buffers on failure. Malloc indextable. (_bfd_stab_cleanup): New function. * libbfd-in.h (_bfd_stab_cleanup): Declare. * libbfd.h: Regnerate. --- bfd/coffgen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bfd/coffgen.c') diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 8eb69af..3e0fbc6 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -3175,7 +3175,10 @@ _bfd_coff_close_and_cleanup (bfd *abfd) if (bfd_get_format (abfd) == bfd_object || bfd_get_format (abfd) == bfd_core) - _bfd_dwarf2_cleanup_debug_info (abfd, &tdata->dwarf2_find_line_info); + { + _bfd_dwarf2_cleanup_debug_info (abfd, &tdata->dwarf2_find_line_info); + _bfd_stab_cleanup (abfd, &tdata->line_info); + } } return _bfd_generic_close_and_cleanup (abfd); } -- cgit v1.1