From 934650ce9ad6fd35dde5a152d1f12d201c3c6a69 Mon Sep 17 00:00:00 2001 From: Matthew Scheffel Date: Wed, 17 Jul 2024 10:24:17 -0300 Subject: [PATCH] ues saturating_sub to avoid panics --- src/core/pdu/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/pdu/mod.rs b/src/core/pdu/mod.rs index 7cc649c8..32ec19c6 100644 --- a/src/core/pdu/mod.rs +++ b/src/core/pdu/mod.rs @@ -119,7 +119,7 @@ impl PduEvent { // deliberately allowing for the possibility of negative age let now: i128 = MilliSecondsSinceUnixEpoch::now().get().into(); let then: i128 = self.origin_server_ts.into(); - let this_age: i128 = now - then; + let this_age: i128 = now.saturating_sub(then); unsigned.insert("age".to_owned(), to_raw_value(&this_age).unwrap()); self.unsigned = Some(to_raw_value(&unsigned).expect("unsigned is valid"));