From dad7fc8fc46874c50931ad71c5c6f559cd0b15f5 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 14 Apr 2024 03:37:33 +0200 Subject: [PATCH] add safety check --- src/chat.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index 67526fe..5f8b4e6 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -188,11 +188,12 @@ impl ChatDB { } } for (index, label) in changes { - vector.remove(index); - vector.splice(index..index, include_db[&label].iter().cloned()); + if index < vector.len() { + vector.remove(index); + vector.splice(index..index, include_db[&label].iter().cloned()); + } } } - return; } pub fn get_chat_by_id(&self, id: &String) -> Result {