Skip to content

Commit 1602cfd

Browse files
committed
Use Self::new in Step methods as a safeguard
This ensures that we never return a non-canonical address from these methods, even if there is a bug in the address calculation. This is important because the `VirtAddr` type guarantees that all addresses are canoncial.
1 parent e2b5d01 commit 1602cfd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/addr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl Step for VirtAddr {
354354
addr.set_bits(47.., 0x1ffff);
355355
}
356356

357-
Some(Self(addr))
357+
Some(Self::new(addr))
358358
}
359359

360360
fn backward_checked(start: Self, count: usize) -> Option<Self> {
@@ -370,7 +370,7 @@ impl Step for VirtAddr {
370370
addr.set_bits(47.., 0);
371371
}
372372

373-
Some(Self(addr))
373+
Some(Self::new(addr))
374374
}
375375
}
376376

0 commit comments

Comments
 (0)