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:
commit
df7a35f196
|
@ -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;
|
||||||
|
if (page_count > page_number) {
|
||||||
|
// Not enough space left to fit entire page range. Breaks outer
|
||||||
|
// loop.
|
||||||
|
base_page_number = -1;
|
||||||
|
} else {
|
||||||
base_page_number = page_number - page_count;
|
base_page_number = page_number - page_count;
|
||||||
base_page_number -= base_page_number % page_scan_stride;
|
base_page_number -= base_page_number % page_scan_stride;
|
||||||
base_page_number += page_scan_stride; // cancel out loop logic
|
base_page_number += page_scan_stride; // cancel out loop logic
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue