Skip to content

Commit a5c0e4b

Browse files
authored
chore: use saturating sub with max_ttl computation (#1792)
### What Use `saturating_sub` when computing `max_ttl`. ### Why Add another defense layer to potential misconfigurations, and improve consistency with math usage in the repository. Closes #1791 ### Known limitations None
1 parent 0e14f5c commit a5c0e4b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

soroban-sdk/src/storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl Storage {
153153
pub fn max_ttl(&self) -> u32 {
154154
let seq = self.env.ledger().sequence();
155155
let max = self.env.ledger().max_live_until_ledger();
156-
max - seq
156+
max.saturating_sub(seq)
157157
}
158158

159159
/// Returns if there is a value stored for the given key in the currently

0 commit comments

Comments
 (0)