From deffdc52482441d2c651c8394fde4d295b0a9fe6 Mon Sep 17 00:00:00 2001 From: Don Ward Date: Wed, 3 Jan 2024 22:49:35 +0000 Subject: [PATCH] Fix heap verification of arrays. The size calculation for integer and real arrays omitted the size of the header, causing spurious verification failures. --- src/runtime/rmemmgt.r | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/runtime/rmemmgt.r b/src/runtime/rmemmgt.r index 6f41d4492..4f26d43ef 100644 --- a/src/runtime/rmemmgt.r +++ b/src/runtime/rmemmgt.r @@ -2468,13 +2468,15 @@ static void vrfy_Intarray(struct b_intarray *b) b, b->listp); } else { struct b_list *hdr = &(b->listp->List); + word blksize; if (&(hdr->listhead->Intarray) != b) { vrfyCrash("Intarray at %p: hdr (%p) bad head ptr (%p)", b, b->listp, hdr->listhead); } - if (b->blksize != (hdr->size*sizeof(b->a[0]))) { + blksize = sizeof(struct b_intarray) + (hdr->size - 1)*sizeof(b->a[0]); + if (b->blksize != blksize) { vrfyCrash("Intarray at %p: wrong size (%ld) should be %ld", - b, b->blksize, (hdr->size*sizeof(b->a[0]))); + b, b->blksize, blksize); } } if (vrfyOpCtrl & (1<listp); } else { struct b_list *hdr = &(b->listp->List); + word blksize; if (&(hdr->listhead->Realarray) != b) { vrfyCrash("Realarray at %p: hdr (%p) bad head ptr (%p)", b, b->listp, hdr->listhead); } - if (b->blksize != (hdr->size*sizeof(b->a[0]))) { + blksize = sizeof(struct b_realarray) + (hdr->size - 1)*sizeof(b->a[0]); + if (b->blksize != blksize) { vrfyCrash("Realarray at %p: wrong size (%ld) should be %ld", - b, b->blksize, (hdr->size*sizeof(b->a[0]))); + b, b->blksize, blksize); } } if (vrfyOpCtrl & (1<