Copilot commented on code in PR #581:
URL: https://github.com/apache/avro-rs/pull/581#discussion_r3566840904


##########
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:
   The doc comment describes the allocation estimate as `n * item_size`, but 
the implementation uses `item_size.max(1)` (treating zero-sized types as size 
1). Please document this clamping so the comment matches the actual behavior 
and error `desired` interpretation.



-- 
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]

Reply via email to