diff options
author | Alan Modra <amodra@gmail.com> | 2020-03-13 13:21:15 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-03-13 14:26:24 +1030 |
commit | fd486f32d15e3299b905084a697fac6349c43f76 (patch) | |
tree | 19dd88d1110f8a2e5ef2baa44a7e180a9d3e2467 /binutils/elfcomm.c | |
parent | 49ba92c0a6765ee7dc3a773c1a044680d29cee0e (diff) | |
download | gdb-fd486f32d15e3299b905084a697fac6349c43f76.zip gdb-fd486f32d15e3299b905084a697fac6349c43f76.tar.gz gdb-fd486f32d15e3299b905084a697fac6349c43f76.tar.bz2 |
asan: more readelf leaks
* elfcomm.c (get_archive_member_name): Always return malloc'd
string or NULL.
* elfedit.c (process_archive): Tidy memory on all return paths.
* readelf.c (process_archive): Likewise.
(process_symbol_table): Likewise.
(ba_cache): New, replacing ..
(get_symbol_for_build_attribute): ..static vars here. Free
strtab and symtab before loading new ones. Reject symtab without
valid strtab in loop, breaking out of loop on valid symtab.
(process_file): Free ba_cache symtab and strtab here, resetting
ba_cache.
Diffstat (limited to 'binutils/elfcomm.c')
-rw-r--r-- | binutils/elfcomm.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/binutils/elfcomm.c b/binutils/elfcomm.c index 87a544b..3060ff1 100644 --- a/binutils/elfcomm.c +++ b/binutils/elfcomm.c @@ -797,7 +797,7 @@ get_archive_member_name (struct archive_info *arch, arch->longnames[j] = '\0'; if (!arch->is_thin_archive || arch->nested_member_origin == 0) - return arch->longnames + k; + return xstrdup (arch->longnames + k); /* PR 17531: file: 2896dc8b. */ if (k >= j) @@ -813,7 +813,7 @@ get_archive_member_name (struct archive_info *arch, if (member_file_name != NULL && setup_nested_archive (nested_arch, member_file_name) == 0) { - member_name = get_archive_member_name_at (nested_arch, + member_name = get_archive_member_name_at (nested_arch, arch->nested_member_origin, NULL); if (member_name != NULL) @@ -825,7 +825,7 @@ get_archive_member_name (struct archive_info *arch, free (member_file_name); /* Last resort: just return the name of the nested archive. */ - return arch->longnames + k; + return xstrdup (arch->longnames + k); } /* We have a normal (short) name. */ @@ -833,7 +833,7 @@ get_archive_member_name (struct archive_info *arch, if (arch->arhdr.ar_name[j] == '/') { arch->arhdr.ar_name[j] = '\0'; - return arch->arhdr.ar_name; + return xstrdup (arch->arhdr.ar_name); } /* The full ar_name field is used. Don't rely on ar_date starting |