We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 33b4c2d commit efd7f00Copy full SHA for efd7f00
src/structures/paging/page.rs
@@ -380,7 +380,16 @@ impl<S: PageSize> Iterator for PageRangeInclusive<S> {
380
fn next(&mut self) -> Option<Self::Item> {
381
if self.start <= self.end {
382
let page = self.start;
383
- self.start += 1;
+
384
+ // If the end of the inclusive range is the maximum page possible for size S,
385
+ // incrementing start until it is greater than the end will cause an integer overflow.
386
+ // So instead, in that case we decrement end rather than incrementing start.
387
+ let max_page_addr = VirtAddr::new(u64::MAX) - (S::SIZE - 1);
388
+ if self.start.start_address() < max_page_addr {
389
+ self.start += 1;
390
+ } else {
391
+ self.end -= 1;
392
+ }
393
Some(page)
394
} else {
395
None
0 commit comments