From 69feea6fe71f6cde3dd8026a7f396eaac2f8ab2f Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Mon, 7 Mar 2011 19:44:19 +0000 Subject: [PATCH] 2011-03-05 Michael Snyder * elfread.c (elf_symtab_read): Stop memory leak. --- gdb/ChangeLog | 2 ++ gdb/elfread.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 85abd06bf81..7f02c9bdf11 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,7 @@ 2011-03-06 Michael Snyder + * elfread.c (elf_symtab_read): Stop memory leak. + * main.c (captured_main): Fix memory leak. 2011-03-07 Andreas Schwab diff --git a/gdb/elfread.c b/gdb/elfread.c index 59a1f7c6ad1..e638a367693 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -243,6 +243,7 @@ elf_symtab_read (struct objfile *objfile, int type, char *filesymname = ""; struct dbx_symfile_info *dbx = objfile->deprecated_sym_stab_info; int stripped = (bfd_get_symcount (objfile->obfd) == 0); + struct cleanup *back_to = make_cleanup (null_cleanup, NULL); for (i = 0; i < number_of_symbols; i++) { @@ -464,6 +465,7 @@ elf_symtab_read (struct objfile *objfile, int type, + (sizeof (CORE_ADDR) * max_index)); sectinfo = (struct stab_section_info *) xmalloc (size); + make_cleanup (xfree, sectinfo); memset (sectinfo, 0, size); sectinfo->num_sections = max_index; if (filesym == NULL) @@ -572,6 +574,7 @@ elf_symtab_read (struct objfile *objfile, int type, } } } + do_cleanups (back_to); } struct build_id -- 2.30.2