diff options
author | Tom Tromey <tom@tromey.com> | 2018-05-18 14:30:25 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-05-21 09:38:36 -0600 |
commit | c0c9f665d9d4cdcef59cc7951396d843a7ea6a48 (patch) | |
tree | 72342cb10fe1ac53937b0e68bf7cb7ffea3ffc46 /gdb | |
parent | 22ca247e9e29c11ccfc99b5d187c7dc925608b78 (diff) | |
download | gdb-c0c9f665d9d4cdcef59cc7951396d843a7ea6a48.zip gdb-c0c9f665d9d4cdcef59cc7951396d843a7ea6a48.tar.gz gdb-c0c9f665d9d4cdcef59cc7951396d843a7ea6a48.tar.bz2 |
Use std::string in reread_symbols
This removes a cleanup from reread_symbols by using std::string. This
fixes a memory leak, because this cleanup is ordinarily discarded, not
run.
Tested by the buildbot.
ChangeLog
2018-05-21 Tom Tromey <tom@tromey.com>
* symfile.c (reread_symbols): Use std::string for original_name.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/symfile.c | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7f281d4..8c6e5ff 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2018-05-21 Tom Tromey <tom@tromey.com> + * symfile.c (reread_symbols): Use std::string for original_name. + +2018-05-21 Tom Tromey <tom@tromey.com> + * dwarf2read.c (dwarf2_read_debug_names): Use std::unique_ptr. (mapped_index_base): Use DISABLE_COPY_AND_ASSIGN. Default constructor. diff --git a/gdb/symfile.c b/gdb/symfile.c index 1f5d761..7bc03fb 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2316,7 +2316,6 @@ reread_symbols (void) struct cleanup *old_cleanups; struct section_offsets *offsets; int num_offsets; - char *original_name; printf_unfiltered (_("`%s' has changed; re-reading symbols.\n"), objfile_name (objfile)); @@ -2382,8 +2381,7 @@ reread_symbols (void) error (_("Can't open %s to read symbols."), obfd_filename); } - original_name = xstrdup (objfile->original_name); - make_cleanup (xfree, original_name); + std::string original_name = objfile->original_name; /* bfd_openr sets cacheable to true, which is what we want. */ if (!bfd_check_format (objfile->obfd, bfd_object)) @@ -2429,8 +2427,9 @@ reread_symbols (void) set_objfile_per_bfd (objfile); objfile->original_name - = (char *) obstack_copy0 (&objfile->objfile_obstack, original_name, - strlen (original_name)); + = (char *) obstack_copy0 (&objfile->objfile_obstack, + original_name.c_str (), + original_name.size ()); /* Reset the sym_fns pointer. The ELF reader can change it based on whether .gdb_index is present, and we need it to |