struct cleanup *back_to;
int ix;
bfd *abfd = NULL;
+ int alloc_len;
/* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */
- link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1
- + 2 * build_id_len + (sizeof ".debug" - 1) + 1);
+ alloc_len = (strlen (debug_file_directory)
+ + (sizeof "/.build-id/" - 1) + 1
+ + 2 * build_id_len + (sizeof ".debug" - 1) + 1);
+ link = (char *) alloca (alloc_len);
/* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
cause "/.build-id/..." lookups. */
size_t size = build_id_len;
char *s;
char *filename = NULL;
+ struct cleanup *inner;
memcpy (link, debugdir, debugdir_len);
s = &link[debugdir_len];
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;