mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-05 17:44:52 +01:00
io/region: remove error handling for impossible cases from decode_chunk()
This commit is contained in:
parent
7c7e36f6be
commit
1d126ba771
1 changed files with 2 additions and 6 deletions
|
@ -43,11 +43,7 @@ where
|
||||||
T: DeserializeOwned,
|
T: DeserializeOwned,
|
||||||
{
|
{
|
||||||
let (len_bytes, buf) = buf.split_at(4);
|
let (len_bytes, buf) = buf.split_at(4);
|
||||||
let len = u32::from_be_bytes(
|
let len = u32::from_be_bytes(len_bytes.try_into().unwrap()) as usize;
|
||||||
len_bytes
|
|
||||||
.try_into()
|
|
||||||
.context("Failed to decode chunk size")?,
|
|
||||||
) as usize;
|
|
||||||
|
|
||||||
if len < 1 || len > buf.len() {
|
if len < 1 || len > buf.len() {
|
||||||
bail!("Invalid chunk size");
|
bail!("Invalid chunk size");
|
||||||
|
@ -55,7 +51,7 @@ where
|
||||||
let buf = &buf[..len];
|
let buf = &buf[..len];
|
||||||
|
|
||||||
let (format, buf) = buf.split_at(1);
|
let (format, buf) = buf.split_at(1);
|
||||||
if !matches!(format, [2]) {
|
if format[0] != 2 {
|
||||||
bail!("Unknown chunk format");
|
bail!("Unknown chunk format");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue