acid/leak: fix endless loop for B2NB(b) == b case (thanks mischief)

This commit is contained in:
cinap_lenrek 2015-10-19 00:20:33 +02:00
parent 5ca4afb249
commit 24d74a4b5f
2 changed files with 6 additions and 6 deletions

View file

@ -41,8 +41,7 @@ dumparena(arena, sum)
if nb == b then {
print("B2NB(", b\A, ") = b\n");
b = atail; // end loop
}
if nb > atail then {
} else if nb > atail then {
b = (Bhdr)(b+4);
print("lost at block ", (b-4)\A, ", scanning forward\n");
while b < atail && b.magic != ALLOC_MAGIC && b.magic != FREE_MAGIC do

View file

@ -206,18 +206,19 @@ checkblock(addr)
defn
checkarena(arena)
{
local atail, b;
local atail, b, nb;
atail = A2TB(arena);
complex Bhdr arena;
b = arena;
while b.magic != ARENATAIL_MAGIC && b < atail do {
checkblock(b);
if B2NB(b) == b then {
nb = B2NB(b);
if nb == b then {
print("B2NB(", b\X, ") = b\n");
b = atail; // end loop
}
b = B2NB(b);
} else
b = nb;
}
checkblock(b);