aboutsummaryrefslogtreecommitdiff
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
parentee42cf8cc569b0ad926df63483075ccd868a10fa (diff)
downloadgdb-5ed6aba41c826194dcc97807392b22a3cefa1d7e.zip
gdb-5ed6aba41c826194dcc97807392b22a3cefa1d7e.tar.gz
gdb-5ed6aba41c826194dcc97807392b22a3cefa1d7e.tar.bz2
Fix memory leaks
-rw-r--r--bfd/ChangeLog17
-rw-r--r--bfd/aoutx.h21
-rw-r--r--bfd/dwarf2.c20
-rw-r--r--bfd/elf-eh-frame.c50
-rw-r--r--bfd/elf.c24
-rw-r--r--bfd/elflink.h1
-rw-r--r--bfd/format.c12
-rw-r--r--bfd/linker.c28
-rw-r--r--bfd/opncls.c7
-rw-r--r--bfd/simple.c7
-rw-r--r--ld/ChangeLog12
-rw-r--r--ld/ldfile.c14
-rw-r--r--ld/ldlang.c1
-rw-r--r--ld/ldmain.c35
-rw-r--r--ld/ldmisc.c31
-rw-r--r--ld/lexsup.c8
16 files changed, 187 insertions, 101 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 5d387c0..13f14d4 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,20 @@
+2003-03-31 David Heine <dlheine@suif.stanford.edu>
+
+ * aoutx.h (aout_link_hash_table_create): Use bfd_malloc instead of
+ bfd_alloc.
+ * dwarf2.c (concat_filename): Always allocate space for the
+ returned filename.
+ (decode_line_info): Free the allocated filename returned by
+ concat_filename.
+ * elf-eh-frame.c (bfd_elf_write_section_eh_frame): Fix memory leaks.
+ * elf.c (copy_private_bfd_data): Likewise.
+ (_bfd_elf_slurp_version_tables): Fix bug freeing contents pointer.
+ * elflink.h (elf_link_sort_relocs): Fix memory leak.
+ * format.c (bfd_check_format_matches): Likewise.
+ * linker.c (bfd_generic_final_link): Likewise.
+ * opncls.c (find_separate_debug_info): Likewise.
+ * simple.c (bfd_simple_get_relocated_section_contents): Likewise.
+
2003-03-28 H.J. Lu <hjl@gnu.org>
* elflink.h (elf_link_add_object_symbols): Correctly combine
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 998bca7..7f02d13 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -1,6 +1,6 @@
/* BFD semi-generic back-end for a.out binaries.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
- 2001, 2002
+ 2001, 2002, 2003
Free Software Foundation, Inc.
Written by Cygnus Support.
@@ -105,9 +105,7 @@ DESCRIPTION
in the @file{config/@var{XXX}.mt} file, and modify @file{configure.in}
to use the
@file{@var{XXX}.mt} file (by setting "<<bfd_target=XXX>>") when your
- configuration is selected.
-
-*/
+ configuration is selected. */
/* Some assumptions:
* Any BFD with D_PAGED set is ZMAGIC, and vice versa.
@@ -157,9 +155,8 @@ DESCRIPTION
The standard records contain only an
address, a symbol index, and a type field. The extended records
(used on 29ks and sparcs) also have a full integer for an
- addend.
+ addend. */
-*/
#ifndef CTOR_TABLE_RELOC_HOWTO
#define CTOR_TABLE_RELOC_IDX 2
#define CTOR_TABLE_RELOC_HOWTO(BFD) \
@@ -230,7 +227,8 @@ reloc_howto_type howto_table_ext[] =
/* Convert standard reloc records to "arelent" format (incl byte swap). */
-reloc_howto_type howto_table_std[] = {
+reloc_howto_type howto_table_std[] =
+{
/* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone. */
HOWTO ( 0, 0, 0, 8, FALSE, 0, complain_overflow_bitfield,0,"8", TRUE, 0x000000ff,0x000000ff, FALSE),
HOWTO ( 1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield,0,"16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
@@ -3067,9 +3065,10 @@ NAME(aout,link_hash_table_create) (abfd)
struct aout_link_hash_table *ret;
bfd_size_type amt = sizeof (struct aout_link_hash_table);
- ret = (struct aout_link_hash_table *) bfd_alloc (abfd, amt);
+ ret = (struct aout_link_hash_table *) bfd_malloc (amt);
if (ret == NULL)
return (struct bfd_link_hash_table *) NULL;
+
if (! NAME(aout,link_hash_table_init) (ret, abfd,
NAME(aout,link_hash_newfunc)))
{
@@ -3906,10 +3905,8 @@ NAME(aout,final_link) (abfd, info, callback)
for (o = abfd->sections; o != NULL; o = o->next)
{
for (p = o->link_order_head; p != NULL; p = p->next)
- {
- if (p->type == bfd_indirect_link_order)
- p->u.indirect.section->linker_mark = TRUE;
- }
+ if (p->type == bfd_indirect_link_order)
+ p->u.indirect.section->linker_mark = TRUE;
}
have_link_order_relocs = FALSE;
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index e7077a1..521bb71 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -1,5 +1,5 @@
/* DWARF 2 support.
- Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+ Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
Adapted from gdb/dwarf2read.c by Gavin Koch of Cygnus Solutions
@@ -911,6 +911,9 @@ add_line_info (table, address, filename, line, column, end_sequence)
info->end_sequence = end_sequence;
}
+/* Extract a fully qualified filename from a line info table.
+ The returned string has been xmalloc'ed. */
+
static char *
concat_filename (table, file)
struct line_info_table* table;
@@ -922,12 +925,13 @@ concat_filename (table, file)
{
(*_bfd_error_handler)
(_("Dwarf Error: mangled line number section (bad file number)."));
- return "<unknown>";
+ return concat ("<unknown>");
}
filename = table->files[file - 1].name;
- if (IS_ABSOLUTE_PATH(filename))
- return filename;
+
+ if (IS_ABSOLUTE_PATH (filename))
+ return concat (filename);
else
{
char* dirname = (table->files[file - 1].dir
@@ -937,9 +941,9 @@ concat_filename (table, file)
/* Not all tools set DW_AT_comp_dir, so dirname may be unknown. The
best we can do is return the filename part. */
if (dirname == NULL)
- return filename;
+ return concat (filename);
else
- return (char*) concat (dirname, "/", filename, NULL);
+ return concat (dirname, "/", filename, NULL);
}
}
@@ -1272,6 +1276,7 @@ decode_line_info (unit, stash)
based, the references are 1 based. */
file = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
line_ptr += bytes_read;
+ free (filename);
filename = concat_filename (table, file);
break;
}
@@ -1296,6 +1301,7 @@ decode_line_info (unit, stash)
default:
{
int i;
+
/* Unknown standard opcode, ignore it. */
for (i = 0; i < lh.standard_opcode_lengths[op_code]; i++)
{
@@ -1305,6 +1311,8 @@ decode_line_info (unit, stash)
}
}
}
+
+ free (filename);
}
return table;
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index 7764074..7d0b52b 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -2,21 +2,21 @@
Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
Written by Jakub Jelinek <jakub@redhat.com>.
-This file is part of BFD, the Binary File Descriptor library.
+ This file is part of BFD, the Binary File Descriptor library.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
@@ -39,7 +39,7 @@ static void write_value
static int cie_compare
PARAMS ((struct cie *, struct cie *));
static int vma_compare
- PARAMS ((const PTR a, const PTR b));
+ PARAMS ((const PTR, const PTR));
/* Helper function for reading uleb128 encoded data. */
@@ -1112,7 +1112,7 @@ vma_compare (a, b)
fde_count x [encoded] initial_loc, fde
(array of encoded pairs containing
FDE initial_location field and FDE address,
- sorted by increasing initial_loc) */
+ sorted by increasing initial_loc). */
bfd_boolean
_bfd_elf_write_section_eh_frame_hdr (abfd, info)
@@ -1125,6 +1125,7 @@ _bfd_elf_write_section_eh_frame_hdr (abfd, info)
bfd_byte *contents;
asection *eh_frame_sec;
bfd_size_type size;
+ bfd_boolean retval;
htab = elf_hash_table (info);
hdr_info = &htab->eh_info;
@@ -1141,15 +1142,18 @@ _bfd_elf_write_section_eh_frame_hdr (abfd, info)
eh_frame_sec = bfd_get_section_by_name (abfd, ".eh_frame");
if (eh_frame_sec == NULL)
- return FALSE;
+ {
+ free (contents);
+ return FALSE;
+ }
memset (contents, 0, EH_FRAME_HDR_SIZE);
- contents[0] = 1; /* Version */
- contents[1] = DW_EH_PE_pcrel | DW_EH_PE_sdata4; /* .eh_frame offset */
+ contents[0] = 1; /* Version. */
+ contents[1] = DW_EH_PE_pcrel | DW_EH_PE_sdata4; /* .eh_frame offset. */
if (hdr_info->array && hdr_info->array_count == hdr_info->fde_count)
{
- contents[2] = DW_EH_PE_udata4; /* FDE count encoding */
- contents[3] = DW_EH_PE_datarel | DW_EH_PE_sdata4; /* search table enc */
+ contents[2] = DW_EH_PE_udata4; /* FDE count encoding. */
+ contents[3] = DW_EH_PE_datarel | DW_EH_PE_sdata4; /* Search table enc. */
}
else
{
@@ -1177,7 +1181,9 @@ _bfd_elf_write_section_eh_frame_hdr (abfd, info)
}
}
- return bfd_set_section_contents (abfd, sec->output_section,
- contents, (file_ptr) sec->output_offset,
- sec->_cooked_size);
+ retval = bfd_set_section_contents (abfd, sec->output_section,
+ contents, (file_ptr) sec->output_offset,
+ sec->_cooked_size);
+ free (contents);
+ return retval;
}
diff --git a/bfd/elf.c b/bfd/elf.c
index 0331f3d..56dfda3 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5068,7 +5068,10 @@ copy_private_bfd_data (ibfd, obfd)
amt += ((bfd_size_type) section_count - 1) * sizeof (asection *);
map = (struct elf_segment_map *) bfd_alloc (obfd, amt);
if (map == NULL)
- return FALSE;
+ {
+ free (sections);
+ return FALSE;
+ }
/* Initialise the fields of the segment map. Set the physical
physical address to the LMA of the first section that has
@@ -5303,7 +5306,10 @@ swap_out_syms (abfd, sttp, relocatable_p)
amt = (bfd_size_type) (1 + symcount) * bed->s->sizeof_sym;
outbound_syms = bfd_alloc (abfd, amt);
if (outbound_syms == NULL)
- return FALSE;
+ {
+ _bfd_stringtab_free (stt);
+ return FALSE;
+ }
symtab_hdr->contents = (PTR) outbound_syms;
outbound_shndx = NULL;
@@ -5313,7 +5319,11 @@ swap_out_syms (abfd, sttp, relocatable_p)
amt = (bfd_size_type) (1 + symcount) * sizeof (Elf_External_Sym_Shndx);
outbound_shndx = bfd_zalloc (abfd, amt);
if (outbound_shndx == NULL)
- return FALSE;
+ {
+ _bfd_stringtab_free (stt);
+ return FALSE;
+ }
+
symtab_shndx_hdr->contents = outbound_shndx;
symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
symtab_shndx_hdr->sh_size = amt;
@@ -5357,7 +5367,10 @@ swap_out_syms (abfd, sttp, relocatable_p)
syms[idx]->name,
TRUE, FALSE);
if (sym.st_name == (unsigned long) -1)
- return FALSE;
+ {
+ _bfd_stringtab_free (stt);
+ return FALSE;
+ }
}
type_ptr = elf_symbol_from (abfd, syms[idx]);
@@ -5446,6 +5459,7 @@ Unable to find equivalent output section for symbol '%s' from section '%s'"),
syms[idx]->name ? syms[idx]->name : "<Local sym>",
sec->name);
bfd_set_error (bfd_error_invalid_operation);
+ _bfd_stringtab_free (stt);
return FALSE;
}
@@ -5906,7 +5920,7 @@ _bfd_elf_slurp_version_tables (abfd)
return TRUE;
error_return:
- if (contents == NULL)
+ if (contents != NULL)
free (contents);
return FALSE;
}
diff --git a/bfd/elflink.h b/bfd/elflink.h
index 3af34ee..3535da5 100644
--- a/bfd/elflink.h
+++ b/bfd/elflink.h
@@ -4855,6 +4855,7 @@ elf_link_sort_relocs (abfd, info, psec)
}
}
+ free (sort);
*psec = reldyn;
return ret;
}
diff --git a/bfd/format.c b/bfd/format.c
index 9af6efc..655ccd9 100644
--- a/bfd/format.c
+++ b/bfd/format.c
@@ -163,7 +163,11 @@ bfd_check_format_matches (abfd, format, matching)
if (!abfd->target_defaulted)
{
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) /* rewind! */
- return FALSE;
+ {
+ if (matching)
+ free ((PTR) matching_vector);
+ return FALSE;
+ }
right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
@@ -214,7 +218,11 @@ bfd_check_format_matches (abfd, format, matching)
abfd->xvec = *target; /* Change BFD's target temporarily. */
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- return FALSE;
+ {
+ if (matching)
+ free ((PTR) matching_vector);
+ return FALSE;
+ }
/* If _bfd_check_format neglects to set bfd_error, assume
bfd_error_wrong_format. We didn't used to even pay any
diff --git a/bfd/linker.c b/bfd/linker.c
index 918f4f8..c0e3236 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -1,23 +1,23 @@
/* linker.c -- BFD linker routines
- Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+ Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support
-This file is part of BFD, the Binary File Descriptor library.
+ This file is part of BFD, the Binary File Descriptor library.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
@@ -2081,12 +2081,12 @@ _bfd_generic_final_link (abfd, info)
input_section,
relocs,
symbols);
+ free (relocs);
if (reloc_count < 0)
return FALSE;
BFD_ASSERT ((unsigned long) reloc_count
== input_section->reloc_count);
o->reloc_count += reloc_count;
- free (relocs);
}
}
if (o->reloc_count > 0)
diff --git a/bfd/opncls.c b/bfd/opncls.c
index 81bd2c8..4771979 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -931,8 +931,13 @@ find_separate_debug_file (abfd, debug_file_directory)
basename = get_debug_link_info (abfd, & crc32);
- if (basename == NULL || strlen (basename) < 1)
+ if (basename == NULL)
return NULL;
+ if (strlen (basename) < 1)
+ {
+ free (basename);
+ return NULL;
+ }
dir = xstrdup (abfd->filename);
BFD_ASSERT (strlen (dir) != 0);
diff --git a/bfd/simple.c b/bfd/simple.c
index 88f1337..30f9be0 100644
--- a/bfd/simple.c
+++ b/bfd/simple.c
@@ -1,5 +1,5 @@
/* simple.c -- BFD simple client routines
- Copyright 2002
+ Copyright 2002, 2003
Free Software Foundation, Inc.
Contributed by MontaVista Software, Inc.
@@ -135,7 +135,7 @@ bfd_simple_get_relocated_section_contents (abfd, sec, outbuf)
struct bfd_link_order link_order;
struct bfd_link_callbacks callbacks;
bfd_byte *contents, *data;
- int storage_needed, number_of_symbols;
+ int storage_needed;
asymbol **symbol_table;
if (! (sec->flags & SEC_RELOC))
@@ -187,7 +187,7 @@ bfd_simple_get_relocated_section_contents (abfd, sec, outbuf)
storage_needed = bfd_get_symtab_upper_bound (abfd);
symbol_table = (asymbol **) bfd_malloc (storage_needed);
- number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
+ bfd_canonicalize_symtab (abfd, symbol_table);
contents = bfd_get_relocated_section_contents (abfd,
&link_info,
@@ -208,5 +208,6 @@ bfd_simple_get_relocated_section_contents (abfd, sec, outbuf)
bfd_link_hash_table_free (abfd, link_info.hash);
+ free (symbol_table);
return contents;
}
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 5a547ff..ea55dbe 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,15 @@
+2003-03-31 David Heine <dlheine@suif.stanford.edu>
+
+ * ldfile.c (ldfile_add_library_path): Always allocate space for
+ the filename.
+ * ldlang.c (lang_register_vers_node): Free the node if it cannot
+ be used.
+ * ldmain.c (set_scripts_dir): Always free the constructed
+ directory name.
+ (add_keepsyms_file): Fix memory leak.
+ * ldmisc.c (vfinfo): Likewise.
+ * lexsup.c (parse_args): Likewise
+
2003-03-25 Stan Cox <scox@redhat.com>
Nick Clifton <nickc@redhat.com>
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. */
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 703779f..5cca71f 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -5276,6 +5276,7 @@ lang_register_vers_node (name, version, deps)
|| (lang_elf_version_info && lang_elf_version_info->name[0] == '\0'))
{
einfo (_("%X%P: anonymous version tag cannot be combined with other version tags\n"));
+ free (version);
return;
}
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;
}
diff --git a/ld/ldmisc.c b/ld/ldmisc.c
index 94b03d4..4f25dbb 100644
--- a/ld/ldmisc.c
+++ b/ld/ldmisc.c
@@ -1,25 +1,25 @@
/* ldmisc.c
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2002
+ 2000, 2002, 2003
Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support.
-This file is part of GLD, the Gnu Linker.
+ This file is part of GLD, the Gnu Linker.
-GLD is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+ GLD is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
-GLD is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ GLD is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with GLD; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with GLD; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
@@ -328,6 +328,9 @@ vfinfo (fp, fmt, arg)
fprintf (fp, ":%u", linenumber);
}
+ if (asymbols != NULL && entry == NULL)
+ free (asymbols);
+
if (discard_last)
{
last_bfd = NULL;
diff --git a/ld/lexsup.c b/ld/lexsup.c
index b6c2fd8..e8c2eba 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -1116,6 +1116,8 @@ parse_args (argc, argv)
case 'Y':
if (strncmp (optarg, "P,", 2) == 0)
optarg += 2;
+ if (default_dirlist != NULL)
+ free (default_dirlist);
default_dirlist = xstrdup (optarg);
break;
case 'y':
@@ -1193,8 +1195,10 @@ parse_args (argc, argv)
lang_leave_group ();
if (default_dirlist != NULL)
- set_default_dirlist (default_dirlist);
-
+ {
+ set_default_dirlist (default_dirlist);
+ free (default_dirlist);
+ }
}
/* Add the (colon-separated) elements of DIRLIST_PTR to the