From c792c0a2e771b7090ec4d07a22fe0849d996b3a8 Mon Sep 17 00:00:00 2001 From: Raffaele Ragni Date: Thu, 3 Oct 2024 13:54:00 +0200 Subject: [PATCH] check bounds --- src/console.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/console.rs b/src/console.rs index ef349bb..aef5b41 100644 --- a/src/console.rs +++ b/src/console.rs @@ -358,6 +358,9 @@ fn style_ansi_text(str: &str, config: &ConsoleConfiguration) -> LayoutJob { .into_iter() .chain(once((str_without_ansi.len(), Default::default()))) { + if last_offset > str_without_ansi.len() || offset > str_without_ansi.len() { + continue; + } // 12345 // 01234 let text = &str_without_ansi[(last_offset)..offset];