From 0d9cf43bf9c623221be6ed9882ec7df6e710566d Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Tue, 22 Apr 2025 11:30:45 +0100 Subject: [PATCH] fix: avoid overflow when checking for previous step --- liana-gui/src/app/state/spend/mod.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/liana-gui/src/app/state/spend/mod.rs b/liana-gui/src/app/state/spend/mod.rs index 7c693703..83cf3d52 100644 --- a/liana-gui/src/app/state/spend/mod.rs +++ b/liana-gui/src/app/state/spend/mod.rs @@ -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) {