summaryrefslogtreecommitdiff
path: root/ld/ldfile.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2003-03-31 18:13:25 +0000
committerNick Clifton <nickc@redhat.com>2003-03-31 18:13:25 +0000
commit0ca6f74e97acea672de228a78631d4528cfa921a (patch)
tree892ef62a80921a3ddde884e31d2ce4b828d7cde3 /ld/ldfile.c
parent1b3cc0cd477af7f3cfc1fc7fb558804accb728d3 (diff)
downloadbinutils-redhat-0ca6f74e97acea672de228a78631d4528cfa921a.tar.gz
Fix memory leaks
Diffstat (limited to 'ld/ldfile.c')
-rw-r--r--ld/ldfile.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/ld/ldfile.c b/ld/ldfile.c
index fbcd7b93d7..0694f9b7fe 100644
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -106,32 +106,38 @@ is_sysrooted_pathname (name, notsame)
return result;
}
+/* Adds NAME to the library search path.
+ Makes a copy of NAME using xmalloc(). */
+
void
ldfile_add_library_path (name, cmdline)
const char *name;
bfd_boolean cmdline;
{
search_dirs_type *new;
+ char *newname;
if (!cmdline && config.only_cmd_line_lib_dirs)
return;
new = (search_dirs_type *) xmalloc (sizeof (search_dirs_type));
new->next = NULL;
- new->name = name;
new->cmdline = cmdline;
*search_tail_ptr = new;
search_tail_ptr = &new->next;
/* If a directory is marked as honoring sysroot, prepend the sysroot path
now. */
- if (new->name[0] == '=')
+ if (name[0] == '=')
{
- new->name = concat (ld_sysroot, &new->name[1], NULL);
+ new->name = concat (ld_sysroot, name + 1, NULL);
new->sysrooted = TRUE;
}
else
- new->sysrooted = is_sysrooted_pathname (new->name, FALSE);
+ {
+ new->name = xstrdup (name);
+ new->sysrooted = is_sysrooted_pathname (name, FALSE);
+ }
}
/* Try to open a BFD for a lang_input_statement. */