Skip to content

Commit ff754e6

Browse files
committed
fix: Remove as conversions in protocol/record.rs
1 parent 2c13f4b commit ff754e6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/protocol/record.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ where
105105
// length
106106
let len = Varint::read(reader)?;
107107
let len = usize::try_from(len.0).map_err(|e| ReadError::Malformed(Box::new(e)))?;
108-
let reader = &mut reader.take(len as u64);
108+
let reader = &mut reader.take(u64::try_from(len).map_err(ReadError::Overflow)?);
109109

110110
// attributes
111111
Int8::read(reader)?;
@@ -399,7 +399,7 @@ where
399399

400400
// check if there is any trailing data because this is likely a bug
401401
let bytes_read = data.position();
402-
let bytes_total = data.into_inner().len() as u64;
402+
let bytes_total = u64::try_from(data.into_inner().len()).map_err(ReadError::Overflow)?;
403403
let bytes_left = bytes_total - bytes_read;
404404
if bytes_left != 0 {
405405
return Err(ReadError::Malformed(

0 commit comments

Comments
 (0)