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

gc.gc: Fix out-of-bounds pagetable access #1199

Merged
merged 1 commit into from Mar 27, 2015

Conversation

CyberShadow
Copy link
Member

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: #1197 (comment)

CyberShadow added a commit to CyberShadow/druntime that referenced this pull request Mar 25, 2015
@rainers
Copy link
Member

rainers commented Mar 27, 2015

IIRC the check i < npages was deliberately chosen to not get wrong results for largest. I guess the fix should go into the while loop accessing pagetable[i+p].

@CyberShadow
Copy link
Member Author

Oh, OK.

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

Found using Vagrind.
@MartinNowak
Copy link
Member

Auto-merge toggled on

MartinNowak added a commit that referenced this pull request Mar 27, 2015
gc.gc: Fix out-of-bounds pagetable access
@MartinNowak MartinNowak merged commit cfe938a into dlang:master Mar 27, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants