Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion float-pigment-consistent-bincode/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ impl<'de, R: BincodeRead<'de>, O: Options> Deserializer<R, O> {
let seg_size = O::IntEncoding::deserialize_u32(self)? as usize;
let ssl = SegmentSizeLimit {
diff: match self.segment_size_limits.last() {
Some(_) => Some(self.reader.barrier() - seg_size),
Some(_) => Some(
self.reader
.barrier()
.checked_sub(seg_size)
.ok_or(ErrorKind::InvalidData)?,
),
None => None,
},
};
Expand Down
4 changes: 4 additions & 0 deletions float-pigment-consistent-bincode/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ pub enum ErrorKind {
Custom(String),
/// No enough segment data to read.
SegmentEnded,
/// Invalid data
InvalidData,
}

impl serde::de::StdError for ErrorKind {
Expand All @@ -52,6 +54,7 @@ impl serde::de::StdError for ErrorKind {
ErrorKind::SizeLimit => None,
ErrorKind::Custom(_) => None,
ErrorKind::SegmentEnded => None,
ErrorKind::InvalidData => None,
}
}
}
Expand Down Expand Up @@ -85,6 +88,7 @@ impl fmt::Display for ErrorKind {
),
ErrorKind::Custom(ref s) => s.fmt(fmt),
ErrorKind::SegmentEnded => write!(fmt, "the segment does not contain enough data"),
ErrorKind::InvalidData => write!(fmt, "the data is invalid"),
}
}
}
Expand Down
Loading