aboutsummaryrefslogtreecommitdiff
path: root/ld/ldmain.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/ldmain.c
parentee42cf8cc569b0ad926df63483075ccd868a10fa (diff)
downloadgdb-5ed6aba41c826194dcc97807392b22a3cefa1d7e.zip
gdb-5ed6aba41c826194dcc97807392b22a3cefa1d7e.tar.gz
gdb-5ed6aba41c826194dcc97807392b22a3cefa1d7e.tar.bz2
Fix memory leaks
Diffstat (limited to 'ld/ldmain.c')
-rw-r--r--ld/ldmain.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 284b975..125dc6a 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -672,22 +672,25 @@ set_scripts_dir ()
{
char *end, *dir;
size_t dirlen;
+ bfd_boolean found;
dir = make_relative_prefix (program_name, BINDIR, SCRIPTDIR);
- if (dir && check_for_scripts_dir (dir))
- /* Success. Don't free dir. */
- return;
-
if (dir)
- free (dir);
+ {
+ found = check_for_scripts_dir (dir);
+ free (dir);
+ if (found)
+ return;
+ }
dir = make_relative_prefix (program_name, TOOLBINDIR, SCRIPTDIR);
- if (dir && check_for_scripts_dir (dir))
- /* Success. Don't free dir. */
- return;
-
if (dir)
- free (dir);
+ {
+ found = check_for_scripts_dir (dir);
+ free (dir);
+ if (found)
+ return;
+ }
if (check_for_scripts_dir (SCRIPTDIR))
/* We've been installed normally. */
@@ -718,15 +721,14 @@ set_scripts_dir ()
dir[dirlen] = '\0';
if (check_for_scripts_dir (dir))
- /* Don't free dir. */
- return;
+ {
+ free (dir);
+ return;
+ }
/* Look for "ldscripts" in <the dir where our binary is>/../lib. */
strcpy (dir + dirlen, "/../lib");
- if (check_for_scripts_dir (dir))
- return;
-
- /* Well, we tried. */
+ check_for_scripts_dir (dir);
free (dir);
}
@@ -832,6 +834,7 @@ add_keepsyms_file (filename)
if (link_info.strip != strip_none)
einfo (_("%P: `-retain-symbols-file' overrides `-s' and `-S'\n"));
+ free (buf);
link_info.strip = strip_some;
}