mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 07:17:27 +00:00
refactor(buf): clean up out of bounds err msg
This commit is contained in:
parent
73f39510fe
commit
e39b880364
1 changed files with 3 additions and 4 deletions
|
|
@ -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<D: StringDecoder>(&mut self, until: Option<D::Delimiter>) -> GDResult<String> {
|
||||
// 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()
|
||||
)));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue