Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
gc.gc: Fix out-of-bounds pagetable access
Browse files Browse the repository at this point in the history
The out-of-bounds access occurs 3 lines below:

`pagetable[i + p]`

We never check that `i + p < npages`.

This patch also acts as a small optimization
(don't look at the last `n-1` pages, because it's impossible
to find a free chunk of at least `n` pages from those positions).

Found using Vagrind.
  • Loading branch information
CyberShadow committed Mar 24, 2015
1 parent f5b62da commit e21c2ac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/gc/gc.d
Expand Up @@ -2940,7 +2940,7 @@ struct LargeObjectPool
while (searchStart < npages && pagetable[searchStart] == B_PAGE)
searchStart += bPageOffsets[searchStart];

for (size_t i = searchStart; i < npages; )
for (size_t i = searchStart; i + n <= npages; )
{
assert(pagetable[i] == B_FREE);
size_t p = 1;
Expand Down

0 comments on commit e21c2ac

Please sign in to comment.