diff options
author | Nick Clifton <nickc@redhat.com> | 2011-03-25 17:14:02 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2011-03-25 17:14:02 +0000 |
commit | 6a6969108e510d407755889162afbe3107f2f3d8 (patch) | |
tree | 5406549d41d5fbfc3d422cbbaf4c8e553711194b /binutils/ar.c | |
parent | 628534583be570e855e7bbce00b7d5e2454d3676 (diff) | |
download | gdb-6a6969108e510d407755889162afbe3107f2f3d8.zip gdb-6a6969108e510d407755889162afbe3107f2f3d8.tar.gz gdb-6a6969108e510d407755889162afbe3107f2f3d8.tar.bz2 |
* ar.c (move_members): Plug memory leak.
Diffstat (limited to 'binutils/ar.c')
-rw-r--r-- | binutils/ar.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/binutils/ar.c b/binutils/ar.c index 0866a54..6320a28 100644 --- a/binutils/ar.c +++ b/binutils/ar.c @@ -1185,8 +1185,9 @@ delete_members (bfd *arch, char **files_to_delete) static void move_members (bfd *arch, char **files_to_move) { - bfd **after_bfd; /* New entries go after this one */ - bfd **current_ptr_ptr; /* cdr pointer into contents */ + bfd **after_bfd; /* New entries go after this one. */ + bfd **current_ptr_ptr; /* cdr pointer into contents. */ + const char *tmp = NULL; for (; *files_to_move; ++files_to_move) { @@ -1194,8 +1195,11 @@ move_members (bfd *arch, char **files_to_move) while (*current_ptr_ptr) { bfd *current_ptr = *current_ptr_ptr; - if (FILENAME_CMP (normalize (*files_to_move, arch), - current_ptr->filename) == 0) + + if (tmp != NULL) + free ((char *) tmp); + tmp = normalize (*files_to_move, arch); + if (FILENAME_CMP (tmp, current_ptr->filename) == 0) { /* Move this file to the end of the list - first cut from where it is. */ @@ -1219,10 +1223,13 @@ move_members (bfd *arch, char **files_to_move) /* xgettext:c-format */ fatal (_("no entry %s in archive %s!"), *files_to_move, arch->filename); - next_file:; + next_file: + ; } write_archive (arch); + if (tmp != NULL) + free ((char *) tmp); } /* Ought to default to replacing in place, but this is existing practice! */ |