Copilot commented on code in PR #3860:
URL: https://github.com/apache/avro/pull/3860#discussion_r3565162311


##########
lang/csharp/src/apache/main/Generic/GenericReader.cs:
##########
@@ -490,8 +496,12 @@ protected virtual object ReadMap(object reuse, MapSchema 
writerSchema, Schema re
         {
             MapSchema rs = (MapSchema)readerSchema;
             object result = CreateMap(reuse, rs);
-            for (int n = (int)d.ReadMapStart(); n != 0; n = 
(int)d.ReadMapNext())
+            // Map keys are strings (>= 1 byte length prefix) plus the value.
+            int minBytes = 1 + MinBytesPerElement(writerSchema.ValueSchema);
+            for (long nl = d.ReadMapStart(); nl != 0; nl = d.ReadMapNext())

Review Comment:
   `minBytes` for maps is computed as `1 + MinBytesPerElement(...)`. Since 
`MinBytesPerElement` can intentionally clamp to `int.MaxValue`, this addition 
can overflow to a negative value in unchecked arithmetic, which then makes 
`minBytesPerElement <= 0` and silently disables the remaining-bytes validation 
for maps.



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