memory: fix out of bounds access in BaseHeap::AllocRange

Prevent out of bounds access of page_table_ by making sure the requested
page count fits in the requested page range.
This commit is contained in:
sephiroth99 2015-07-30 02:27:55 -04:00
parent a9b89a790b
commit 510a8e59cf
1 changed files with 5 additions and 0 deletions

View File

@ -615,6 +615,11 @@ bool BaseHeap::AllocRange(uint32_t low_address, uint32_t high_address,
high_page_number =
std::min(uint32_t(page_table_.size()) - 1, high_page_number);
if (page_count > (high_page_number - low_page_number)) {
XELOGE("BaseHeap::Alloc page count too big for requested range");
return false;
}
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
// Find a free page range.