Merge pull request #417 from Rhodan81/master

Fix crash in memory allocation when there is no space to fit entire page
This commit is contained in:
Ben Vanik 2015-09-05 07:26:34 -07:00
commit df7a35f196
1 changed files with 9 additions and 3 deletions

View File

@ -650,9 +650,15 @@ bool BaseHeap::AllocRange(uint32_t low_address, uint32_t high_address,
// At least one page in the range is used, skip to next. // At least one page in the range is used, skip to next.
// We know we'll be starting at least before this page. // We know we'll be starting at least before this page.
any_taken = true; any_taken = true;
base_page_number = page_number - page_count; if (page_count > page_number) {
base_page_number -= base_page_number % page_scan_stride; // Not enough space left to fit entire page range. Breaks outer
base_page_number += page_scan_stride; // cancel out loop logic // loop.
base_page_number = -1;
} else {
base_page_number = page_number - page_count;
base_page_number -= base_page_number % page_scan_stride;
base_page_number += page_scan_stride; // cancel out loop logic
}
break; break;
} }
} }