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/elfedit.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/elfedit.c')
-rw-r--r-- | binutils/elfedit.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/binutils/elfedit.c b/binutils/elfedit.c index e94b677..3a14c60 100644 --- a/binutils/elfedit.c +++ b/binutils/elfedit.c @@ -616,6 +616,7 @@ process_archive (const char * file_name, FILE * file, if (qualified_name == NULL) { error (_("%s: bad archive file name\n"), file_name); + free (name); ret = 1; break; } @@ -626,8 +627,10 @@ process_archive (const char * file_name, FILE * file, FILE *member_file; char *member_file_name = adjust_relative_path (file_name, name, namelen); + free (name); if (member_file_name == NULL) { + free (qualified_name); ret = 1; break; } @@ -638,6 +641,7 @@ process_archive (const char * file_name, FILE * file, error (_("Input file '%s' is not readable\n"), member_file_name); free (member_file_name); + free (qualified_name); ret = 1; break; } @@ -648,9 +652,12 @@ process_archive (const char * file_name, FILE * file, fclose (member_file); free (member_file_name); + free (qualified_name); } else if (is_thin_archive) { + free (name); + /* This is a proxy for a member of a nested archive. */ archive_file_offset = arch.nested_member_origin + sizeof arch.arhdr; @@ -661,6 +668,7 @@ process_archive (const char * file_name, FILE * file, { error (_("%s: failed to seek to archive member\n"), nested_arch.file_name); + free (qualified_name); ret = 1; break; } @@ -669,6 +677,7 @@ process_archive (const char * file_name, FILE * file, } else { + free (name); archive_file_offset = arch.next_arhdr_offset; arch.next_arhdr_offset += archive_file_size; |