fix: avoid overflow when checking for previous step

This commit is contained in:
Michael Mallan 2025-04-22 11:30:45 +01:00
parent 83c90b085a
commit 0d9cf43bf9
No known key found for this signature in database
GPG Key ID: 5177CDCEDB0EABEB

View File

@ -102,10 +102,11 @@ impl State for CreateSpendPanel {
}
}
if matches!(message, Message::View(view::Message::Previous))
&& self.steps.get(self.current - 1).is_some()
{
self.current -= 1;
if matches!(message, Message::View(view::Message::Previous)) {
let previous = self.current.saturating_sub(1);
if self.steps.get(previous).is_some() {
self.current = previous;
}
}
if let Some(step) = self.steps.get_mut(self.current) {