From d276842fd24985b3fe7fcbad34d19f8e877fbb44 Mon Sep 17 00:00:00 2001 From: jrx Date: Fri, 9 Aug 2024 15:00:29 +0200 Subject: [PATCH] another `off by one` --- src/decoders/decoder.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/decoders/decoder.rs b/src/decoders/decoder.rs index 7004f1e..aedc4ec 100644 --- a/src/decoders/decoder.rs +++ b/src/decoders/decoder.rs @@ -37,10 +37,14 @@ pub(crate) fn check_objects( let mut index = item_index; let precision_item = 0x12; + if index >= message_values.len() { + return format!("Index out of bounds for FirehoseItemInfo Vec. Got adjusted index {}, Vec size is {}. This should not have happened", index, message_values.len()); + } + // Increment index get the actual firehose item data if item_type == &precision_item { index += 1; - if index > message_values.len() { + if index >= message_values.len() { return format!("Index out of bounds for FirehoseItemInfo Vec. Got adjusted index {}, Vec size is {}. This should not have happened", index, message_values.len()); } }