Skip to content

Commit a2260f8

Browse files
committed
avoid substaction overflow
1 parent 988b67e commit a2260f8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/shims/time.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ impl Clock {
111111
(
112112
Instant::Virtual { nanoseconds },
113113
Clock::Virtual { nanoseconds: current_ns },
114-
) => Duration::from_nanos(nanoseconds - current_ns.load(Ordering::Relaxed)),
114+
) =>
115+
Duration::from_nanos(
116+
nanoseconds.saturating_sub(current_ns.load(Ordering::Relaxed)),
117+
),
115118
_ => panic!(),
116119
},
117120
Time::RealTime(time) =>

0 commit comments

Comments
 (0)