iemejia commented on code in PR #581:
URL: https://github.com/apache/avro-rs/pull/581#discussion_r3566848958
##########
avro/src/util.rs:
##########
@@ -184,6 +184,39 @@ pub(crate) fn safe_len(len: usize) -> AvroResult<usize> {
}
}
+/// Bound the cumulative number of elements a collection (array or map) may
hold.
+///
+/// [`safe_len`] guards byte-length allocations, but an array or map block is a
+/// count of elements, and reserving capacity for `n` elements allocates at
+/// least `n * item_size` bytes (`item_size` being the in-memory size of a
+/// decoded element; a collection may over-allocate beyond that for growth or
+/// internal metadata, so this is a lower-bound estimate). A malicious or
Review Comment:
Fixed in f76632d: the doc now notes that `item_size` is clamped to at least
1 (a zero-sized element type is treated as one byte), so the reported `desired`
allocation is `total_items * max(item_size, 1)`, matching the implementation.
--
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]