Fix lrealpath memory leak in build_id_to_debug_bfd
[deliverable/binutils-gdb.git] / gdb / build-id.c
index ebf9f4534807650f9bcf6a169e18539b75a70eb9..c89cd55c262ab9bbc10f282b36b811a08f0fb9d3 100644 (file)
@@ -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;
 
This page took 0.033759 seconds and 4 git commands to generate.