Checked add for duration update

Co-authored-by: Ralf Jung <post@ralfj.de>
This commit is contained in:
byt 2024-06-09 17:59:30 +08:00 committed by tiif
parent d0fb350b6a
commit e85c521f37

View file

@ -102,7 +102,7 @@ impl Clock {
ClockKind::Virtual { nanoseconds } => {
// Just pretend that we have slept for some time.
let nanos: u128 = duration.as_nanos();
nanoseconds.update(|x| x + nanos);
nanoseconds.update(|x| x.checked_add(nanos).expect("Miri's virtual clock cannot represent an execution this long"));
}
}
}