alpha-vms: memory leak
[binutils-gdb.git] / bfd / elfcode.h
index e7dfdee95e9c7e6672dbdd14379206837df1ef26..b67ea8c7d2e88dd644d2da4b0ed53f4203ddfb32 100644 (file)
@@ -1234,13 +1234,10 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
        {
          if (bfd_seek (abfd, verhdr->sh_offset, SEEK_SET) != 0)
            goto error_return;
-
-         xverbuf = (Elf_External_Versym *) bfd_malloc (verhdr->sh_size);
+         xverbuf = (Elf_External_Versym *)
+           _bfd_malloc_and_read (abfd, verhdr->sh_size, verhdr->sh_size);
          if (xverbuf == NULL && verhdr->sh_size != 0)
            goto error_return;
-
-         if (bfd_bread (xverbuf, verhdr->sh_size, abfd) != verhdr->sh_size)
-           goto error_return;
        }
 
       /* Skip first symbol, which is a null dummy.  */
@@ -1401,7 +1398,7 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
     free (isymbuf);
   return symcount;
 
-error_return:
+ error_return:
   if (xverbuf != NULL)
     free (xverbuf);
   if (isymbuf != NULL && hdr->contents != (unsigned char *) isymbuf)
@@ -1429,14 +1426,11 @@ elf_slurp_reloc_table_from_section (bfd *abfd,
   int entsize;
   unsigned int symcount;
 
-  allocated = bfd_malloc (rel_hdr->sh_size);
+  if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0)
+    return FALSE;
+  allocated = _bfd_malloc_and_read (abfd, rel_hdr->sh_size, rel_hdr->sh_size);
   if (allocated == NULL)
-    goto error_return;
-
-  if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0
-      || (bfd_bread (allocated, rel_hdr->sh_size, abfd)
-         != rel_hdr->sh_size))
-    goto error_return;
+    return FALSE;
 
   native_relocs = (bfd_byte *) allocated;