iemejia commented on code in PR #3928:
URL: https://github.com/apache/avro/pull/3928#discussion_r3737645139
##########
lang/java/avro/src/main/java/org/apache/avro/io/FastReaderBuilder.java:
##########
@@ -657,19 +678,24 @@
@Override
public Object read(Object reuse, Decoder decoder) throws IOException {
- long l = decoder.readMapStart();
- Map<Object, Object> targetMap = new HashMap<>();
-
- while (l > 0) {
- for (int i = 0; i < l; i++) {
- Object key = keyReader.read(null, decoder);
- Object value = valueReader.read(null, decoder);
- targetMap.put(key, value);
+ SystemLimitException.incrementDecodeDepth();
+ try {
+ long l = decoder.readMapStart();
+ Map<Object, Object> targetMap = new HashMap<>();
+
+ while (l > 0) {
+ for (int i = 0; i < l; i++) {
Review Comment:
Fixed in d6f144c. Changed the fast reader's `MapReader` loop counter from
`int` to `long` so it is compared against the `long` block count without
narrowing. A map block count above `Integer.MAX_VALUE` would otherwise overflow
the `int` counter and never satisfy the loop condition. This matches the array
reader in the same file, which already uses a `long` counter.
--
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]