rx-elf FAIL: SHF_GNU_RETAIN sections 27
[binutils-gdb.git] / bfd / vms-lib.c
index 6a8a76ecb034bb9b155dee595d07ca658e2c0ba6..93791088bd4b1c7fecf81e63c7f669fc8211504d 100644 (file)
@@ -277,7 +277,8 @@ vms_traverse_index (bfd *abfd, unsigned int vbn, struct carsym_mem *cs,
       unsigned int flags;
 
       /* Extract key length.  */
-      if (bfd_libdata (abfd)->ver == LBR_MAJORID)
+      if (bfd_libdata (abfd)->ver == LBR_MAJORID
+         && offsetof (struct vms_idx, keyname) <= (size_t) (endp - p))
        {
          struct vms_idx *ridx = (struct vms_idx *)p;
 
@@ -288,7 +289,8 @@ vms_traverse_index (bfd *abfd, unsigned int vbn, struct carsym_mem *cs,
          flags = 0;
          keyname = ridx->keyname;
        }
-      else if (bfd_libdata (abfd)->ver == LBR_ELFMAJORID)
+      else if (bfd_libdata (abfd)->ver == LBR_ELFMAJORID
+              && offsetof (struct vms_elfidx, keyname) <= (size_t) (endp - p))
        {
          struct vms_elfidx *ridx = (struct vms_elfidx *)p;
 
@@ -2045,8 +2047,7 @@ _bfd_vms_lib_build_map (unsigned int nbr_modules,
        {
          if (storage > syms_max)
            {
-             if (syms_max > 0)
-               free (syms);
+             free (syms);
              syms_max = storage;
              syms = (asymbol **) bfd_malloc (syms_max);
              if (syms == NULL)
@@ -2097,10 +2098,8 @@ _bfd_vms_lib_build_map (unsigned int nbr_modules,
   return TRUE;
 
  error_return:
-  if (syms_max > 0)
-    free (syms);
-  if (map != NULL)
-    free (map);
+  free (syms);
+  free (map);
   return FALSE;
 }