mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Prevent subtract with underflow
This commit is contained in:
@@ -95,8 +95,10 @@ impl OwnStates {
|
|||||||
///
|
///
|
||||||
/// Keep index if possible, otherwise set to lenght - 1
|
/// Keep index if possible, otherwise set to lenght - 1
|
||||||
pub fn fix_list_index(&mut self) {
|
pub fn fix_list_index(&mut self) {
|
||||||
if self.list_index >= self.list_len {
|
if self.list_index >= self.list_len && self.list_len > 0 {
|
||||||
self.list_index = self.list_len - 1;
|
self.list_index = self.list_len - 1;
|
||||||
|
} else if self.list_len == 0 {
|
||||||
|
self.list_index = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user