aboutsummaryrefslogtreecommitdiff
path: root/bfd/vms-misc.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-12-29 12:55:34 +1030
committerAlan Modra <amodra@gmail.com>2019-12-29 21:26:00 +1030
commit37d2e9c7b10e298403640fdd38a50fedae8525b2 (patch)
tree44a8f091400c523623a87c15d1373dcdae51619a /bfd/vms-misc.c
parentf5d35bb7a5789950efd5f03b270d4c5f774eaba9 (diff)
downloadgdb-37d2e9c7b10e298403640fdd38a50fedae8525b2.zip
gdb-37d2e9c7b10e298403640fdd38a50fedae8525b2.tar.gz
gdb-37d2e9c7b10e298403640fdd38a50fedae8525b2.tar.bz2
asan: alpha-vms: memory leaks
* vms-misc.c (_bfd_vms_save_sized_string): Add abfd param, make size a size_t. Use bfd_alloc rather than bfd_malloc. (_bfd_vms_save_counted_string): Similarly. * vms.h (_bfd_vms_save_sized_string): Update prototype. (_bfd_vms_save_counted_string): Likewise. * vms-alpha.c (_bfd_vms_slurp_ehdr): Adjust _bfd_vms_save_counted_string and bfd_vms_save_sized_string calls. (_bfd_vms_slurp_egsd, parse_module): Likewise. (_bfd_vms_slurp_eisd): Likewise. Check return status. (alpha_vms_bfd_link_hash_table_free): New function. (alpha_vms_bfd_link_hash_table_create): Arrange to call it. (vms_close_and_cleanup): Free more memory. Don't release tdata.
Diffstat (limited to 'bfd/vms-misc.c')
-rw-r--r--bfd/vms-misc.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/bfd/vms-misc.c b/bfd/vms-misc.c
index bc42289..c94f1c3 100644
--- a/bfd/vms-misc.c
+++ b/bfd/vms-misc.c
@@ -139,13 +139,19 @@ _bfd_hexdump (int level, unsigned char *ptr, int size, int offset)
Size is string size (size of record). */
char *
-_bfd_vms_save_sized_string (unsigned char *str, unsigned int size)
+_bfd_vms_save_sized_string (bfd *abfd, unsigned char *str, size_t size)
{
- char *newstr = bfd_malloc ((bfd_size_type) size + 1);
+ char *newstr;
+ if (size == (size_t) -1)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return NULL;
+ }
+ newstr = bfd_alloc (abfd, size + 1);
if (newstr == NULL)
return NULL;
- memcpy (newstr, (char *) str, (size_t) size);
+ memcpy (newstr, str, size);
newstr[size] = 0;
return newstr;
@@ -155,13 +161,13 @@ _bfd_vms_save_sized_string (unsigned char *str, unsigned int size)
PTR points to size byte on entry. */
char *
-_bfd_vms_save_counted_string (unsigned char *ptr, unsigned int maxlen)
+_bfd_vms_save_counted_string (bfd *abfd, unsigned char *ptr, size_t maxlen)
{
unsigned int len = *ptr++;
if (len > maxlen)
return NULL;
- return _bfd_vms_save_sized_string (ptr, len);
+ return _bfd_vms_save_sized_string (abfd, ptr, len);
}
/* Object output routines. */