diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 19144edf34..a52624b453 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2015-06-24 Keith Seitz + + * build-id.c (build_id_to_debug_bfd): Add cleanup to free + return value from lrealpath. + 2015-06-24 Mike Frysinger * remote-sim.c (gdbsim_open): Move sysroot update to the top. diff --git a/gdb/build-id.c b/gdb/build-id.c index ebf9f45348..c89cd55c26 100644 --- a/gdb/build-id.c +++ b/gdb/build-id.c @@ -93,6 +93,7 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) size_t size = build_id_len; char *s; char *filename = NULL; + struct cleanup *inner; memcpy (link, debugdir, debugdir_len); s = &link[debugdir_len]; @@ -116,7 +117,10 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) continue; /* We expect to be silent on the non-existing files. */ + inner = make_cleanup (xfree, filename); abfd = gdb_bfd_open (filename, gnutarget, -1); + do_cleanups (inner); + if (abfd == NULL) continue;