Skip to content

Commit

Permalink
Merge pull request #354 from Don-Ward/fixHeapVerifier
Browse files Browse the repository at this point in the history
Fix heap verification of arrays.
  • Loading branch information
Jafaral authored Jan 4, 2024
2 parents c4cce4e + deffdc5 commit 35e04e4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/runtime/rmemmgt.r
Original file line number Diff line number Diff line change
Expand Up @@ -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<<T_Intarray)) vrfyLog("Intarray at %p verified", b);
Expand All @@ -2494,13 +2496,15 @@ static void vrfy_Realarray(struct b_realarray *b)
b, b->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<<T_Realarray)) vrfyLog("Realarray at %p verified", b);
Expand Down

0 comments on commit 35e04e4

Please sign in to comment.