aboutsummaryrefslogtreecommitdiff
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
commit5ed6aba41c826194dcc97807392b22a3cefa1d7e (patch)
tree8e87d13436f477ba70e90e9109c69dcaf3d18e27 /ld/ldfile.c
parentee42cf8cc569b0ad926df63483075ccd868a10fa (diff)
downloadfsf-binutils-gdb-5ed6aba41c826194dcc97807392b22a3cefa1d7e.zip
fsf-binutils-gdb-5ed6aba41c826194dcc97807392b22a3cefa1d7e.tar.gz
fsf-binutils-gdb-5ed6aba41c826194dcc97807392b22a3cefa1d7e.tar.bz2
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 fbcd7b9..0694f9b 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. */