Commit 643794ce authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(l2gi_prev): Don't read memory before the start of an array.

parent 2d7cb21e
......@@ -1368,6 +1368,8 @@ l2gi_next(L2g_iterator *l2gi)
const struct l2g_block_info *binfo;
int arrindex;
assert(!l2gi->search_ended);
l2g = l2gi->l2g;
arrindex = l2gi->arrindex + 1;
for (binfo = l2gi->binfo;
......@@ -1457,11 +1459,12 @@ l2gi_prev(L2g_reverse_iterator *l2gi)
const struct l2g_block_info *binfo;
int arrindex;
assert(!l2gi->search_ended);
l2g = l2gi->l2g;
arrindex = l2gi->arrindex - 1;
for (binfo = l2gi->binfo;
binfo >= l2g->blocks;
--binfo, arrindex = binfo->first_free - 1)
binfo = l2gi->binfo;
while (1)
{
for (; arrindex >= 0; --arrindex)
{
......@@ -1482,10 +1485,16 @@ l2gi_prev(L2g_reverse_iterator *l2gi)
return;
}
}
}
l2gi->search_ended = 1;
return;
if (binfo == l2g->blocks)
{
l2gi->search_ended = 1;
return;
}
--binfo;
arrindex = binfo->first_free - 1;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment