Skip to content

Commit

Permalink
std-support: fix potential underflow in duration_since
Browse files Browse the repository at this point in the history
Signed-off-by: Jiaqi Gao <jiaqi.gao@intel.com>
  • Loading branch information
gaojiaqi7 committed May 6, 2024
1 parent da43b80 commit 8dad300
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/std-support/rust-std-stub/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub const UNIX_EPOCH: SystemTime = SystemTime(0);

impl SystemTime {
pub fn duration_since(&self, time: SystemTime) -> Result<Duration, SystemTimeError> {
if self.0 - time.0 > 0 {
if self.0 >= time.0 {
Ok(Duration::new(self.0 - time.0, 0))
} else {
Err(SystemTimeError)
Expand Down

0 comments on commit 8dad300

Please sign in to comment.