chaokunyang commented on code in PR #3421:
URL: https://github.com/apache/fory/pull/3421#discussion_r2868938065
##########
rust/fory-core/src/serializer/map.rs:
##########
@@ -698,18 +710,30 @@ impl<K: Serializer + ForyDefault + Ord + std::hash::Hash,
V: Serializer + ForyDe
fn fory_read_data(context: &mut ReadContext) -> Result<Self, Error> {
let len = context.reader.read_varuint32()?;
- let mut map = BTreeMap::<K, V>::new();
if len == 0 {
- return Ok(map);
+ return Ok(BTreeMap::new());
+ }
+ let remaining = context
+ .reader
+ .bf
+ .len()
+ .saturating_sub(context.reader.cursor);
+ if len as usize > remaining {
Review Comment:
This won't work for streaming deserialization
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]