diff options
Diffstat (limited to 'bfd/vms-misc.c')
-rw-r--r-- | bfd/vms-misc.c | 16 |
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. */ |