diff options
author | Alan Modra <amodra@gmail.com> | 2023-06-06 09:50:56 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-06-07 11:05:11 +0930 |
commit | f5c0d77088ee2878813861b5b72fa64001f1831a (patch) | |
tree | 2100ddf09f08bce0a2031f6e7981992ddc701df8 /binutils/objcopy.c | |
parent | d5b46032b8a6df2d8dc004759bffb6cd7ecdbe14 (diff) | |
download | gdb-f5c0d77088ee2878813861b5b72fa64001f1831a.zip gdb-f5c0d77088ee2878813861b5b72fa64001f1831a.tar.gz gdb-f5c0d77088ee2878813861b5b72fa64001f1831a.tar.bz2 |
objcopy memory leaks after errors
These aren't important at all, but tidy them in case they obscure
other more important leaks.
* objcopy (copy_file): Close input bfd after errors.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r-- | binutils/objcopy.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c index ac40da8..4140077 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -3821,6 +3821,8 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, if (ibfd == NULL || bfd_stat (ibfd, in_stat) != 0) { bfd_nonfatal_message (input_filename, NULL, NULL, NULL); + if (ibfd != NULL) + bfd_close (ibfd); status = 1; return; } @@ -3890,6 +3892,7 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, { close (ofd); bfd_nonfatal_message (output_filename, NULL, NULL, NULL); + bfd_close (ibfd); status = 1; return; } @@ -3922,6 +3925,7 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, { close (ofd); bfd_nonfatal_message (output_filename, NULL, NULL, NULL); + bfd_close (ibfd); status = 1; return; } @@ -3970,6 +3974,7 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, if (core_error == bfd_error_file_ambiguously_recognized) list_matching_formats (core_matching); + bfd_close (ibfd); status = 1; } } |