diff --git a/crates/lib/src/buffer.rs b/crates/lib/src/buffer.rs index 5485d90..549fabf 100644 --- a/crates/lib/src/buffer.rs +++ b/crates/lib/src/buffer.rs @@ -146,11 +146,10 @@ impl<'a, B: ByteOrder> Buffer<'a, B> { /// Returns a `BufferError` if there is an error decoding the string. pub fn read_string(&mut self, until: Option) -> GDResult { // Check if the cursor is out of bounds. - let remaining = self.remaining_length(); - if self.cursor > remaining { + if self.cursor > self.remaining_length() { return Err(PacketUnderflow.context(format!( - "Cursor position {} is out of bounds when reading string. Remaining bytes: {remaining}", - self.cursor + "Cursor position {} is out of bounds when reading string. Buffer length: {}", + self.cursor, self.data.len() ))); }