aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Gingold <gingold@adacore.com>2010-05-03 10:23:33 +0000
committerTristan Gingold <gingold@adacore.com>2010-05-03 10:23:33 +0000
commitab94b07c4b703fe5d21d08294f43b4c1499db16f (patch)
tree9256df5b3d4d450b2b9372c08df2a2e331b076df
parent7984d53228ace0dd98b75f566e62f1a0bb2a4a99 (diff)
downloadgdb-ab94b07c4b703fe5d21d08294f43b4c1499db16f.zip
gdb-ab94b07c4b703fe5d21d08294f43b4c1499db16f.tar.gz
gdb-ab94b07c4b703fe5d21d08294f43b4c1499db16f.tar.bz2
bfd/
2010-05-03 Tristan Gingold <gingold@adacore.com> * vms-lib.c (_bfd_vms_lib_archive_p): Adjust for a possible empty next array. (vms_lib_dcx): Adjust for the above change.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/vms-lib.c28
2 files changed, 27 insertions, 7 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 74dd28b..4caa817 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2010-05-03 Tristan Gingold <gingold@adacore.com>
+
+ * vms-lib.c (_bfd_vms_lib_archive_p): Adjust for a possible empty
+ next array.
+ (vms_lib_dcx): Adjust for the above change.
+
2010-04-30 H.J. Lu <hongjiu.lu@intel.com>
PR ld/11542
diff --git a/bfd/vms-lib.c b/bfd/vms-lib.c
index bd5ecb7..bbef19c 100644
--- a/bfd/vms-lib.c
+++ b/bfd/vms-lib.c
@@ -552,6 +552,7 @@ _bfd_vms_lib_archive_p (bfd *abfd, enum vms_lib_kind kind)
struct dcxsbm_desc *sbmdesc = &tdata->dcxsbm[i];
unsigned int sbm_len;
unsigned int sbm_sz;
+ unsigned int off;
unsigned char *data = (unsigned char *)sbm;
unsigned char *buf1;
unsigned int l, j;
@@ -565,16 +566,28 @@ _bfd_vms_lib_archive_p (bfd *abfd, enum vms_lib_kind kind)
sbmdesc->max_char = sbm->max_char;
sbm_len = sbmdesc->max_char - sbmdesc->min_char + 1;
l = (2 * sbm_len + 7) / 8;
- BFD_ASSERT (sbm_sz >= sizeof (struct vms_dcxsbm) + l + 3 * sbm_len);
+ BFD_ASSERT
+ (sbm_sz >= sizeof (struct vms_dcxsbm) + l + 3 * sbm_len
+ || (tdata->nbr_dcxsbm == 1
+ && sbm_sz >= sizeof (struct vms_dcxsbm) + l + sbm_len));
sbmdesc->flags = (unsigned char *)bfd_alloc (abfd, l);
memcpy (sbmdesc->flags, data + bfd_getl16 (sbm->flags), l);
sbmdesc->nodes = (unsigned char *)bfd_alloc (abfd, 2 * sbm_len);
memcpy (sbmdesc->nodes, data + bfd_getl16 (sbm->nodes), 2 * sbm_len);
- sbmdesc->next = (unsigned short *)bfd_alloc
- (abfd, sbm_len * sizeof (unsigned short));
- buf1 = data + bfd_getl16 (sbm->next);
- for (j = 0; j < sbm_len; j++)
- sbmdesc->next[j] = bfd_getl16 (buf1 + j * 2);
+ off = bfd_getl16 (sbm->next);
+ if (off != 0)
+ {
+ sbmdesc->next = (unsigned short *)bfd_alloc
+ (abfd, sbm_len * sizeof (unsigned short));
+ buf1 = data + off;
+ for (j = 0; j < sbm_len; j++)
+ sbmdesc->next[j] = bfd_getl16 (buf1 + j * 2);
+ }
+ else
+ {
+ BFD_ASSERT (tdata->nbr_dcxsbm == 1);
+ sbmdesc->next = NULL;
+ }
}
free (buf);
}
@@ -850,7 +863,8 @@ vms_lib_dcx (struct vms_lib_iovec *vec, unsigned char *buf, file_ptr nbytes)
{
unsigned char v = sbm->nodes[offset];
- sbm = vec->dcxsbms + sbm->next[v];
+ if (sbm->next != NULL)
+ sbm = vec->dcxsbms + sbm->next[v];
offset = 0;
res++;