mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-17 07:53:51 +08:00
Close memory and resource leaks detected by coverity in the binutils directory.
* objcopy.c (add_specific_symbols): Free buffer on exit. (add_redefine_syms_file): Close file handle on exit. (copy_object): Close file handle on early exit. Free buffer on early exit. Free gaps buffers once they are no longer needed. * dwarf.c (display_debug_frames): Free allocated memory on exit. (load_separate_debug_info): Free allocate memory on early exit.
This commit is contained in:
@ -1142,6 +1142,8 @@ add_specific_symbols (const char *filename, htab_t htab)
|
||||
line = eol;
|
||||
line_count ++;
|
||||
}
|
||||
|
||||
free (buffer);
|
||||
}
|
||||
|
||||
/* See whether a symbol should be stripped or kept
|
||||
@ -1817,6 +1819,7 @@ add_redefine_syms_file (const char *filename)
|
||||
fatal (_("%s:%d: premature end of file"), filename, lineno);
|
||||
|
||||
free (buf);
|
||||
fclose (file);
|
||||
}
|
||||
|
||||
/* Copy unknown object file IBFD onto OBFD.
|
||||
@ -2823,6 +2826,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
|
||||
pdump->filename,
|
||||
strerror (errno));
|
||||
free (contents);
|
||||
fclose (f);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -3153,6 +3157,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
|
||||
off, now))
|
||||
{
|
||||
bfd_nonfatal_message (NULL, obfd, osections[i], NULL);
|
||||
free (buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -3161,6 +3166,10 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free (buf);
|
||||
free (gaps);
|
||||
gaps = NULL;
|
||||
}
|
||||
|
||||
/* Allow the BFD backend to copy any private data it understands
|
||||
|
Reference in New Issue
Block a user