Attempt to add with overflow
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 162
- PR merge metrics
- No merged PRs in 30d
Description
The scenario. When a huge data chunk needs to be serialized. First it takes a very very long time and then the following issue occurs.
attempt to add with overflow
thread 'data_storage::file_format::block::tests::creation_with_data_too_big_test' (778007) panicked at /Users//.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rmp-serde-1.3.1/src/encode.rs:527:17:
attempt to add with overflow
it is in the encode this function:
```rust
fn serialize_element(&mut self, value: &T) -> Result<(), Self::Error> {
match self.compound.as_mut() {
None => value.serialize(&mut *self.se),
Some(buf) => {
value.serialize(&mut buf.se)?;
buf.elem_count += 1;
Ok(())
},
}
}
```
I think the fix would be to increase the the elem_count from u32 to an u64 for good measure.
Current:
```rust
#[derive(Debug)]
struct UnknownLengthCompound {
se: Serializer, DefaultConfig>,
elem_count: u32,
}
```
I can myself do this change and create a pull request. Though it is this small, so maybe you can fix it.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.