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


##########
lang/perl/lib/Avro/BinaryDecoder.pm:
##########
@@ -220,8 +339,26 @@ sub skip_block {
     my $block_count = decode_long($class, undef, undef, $reader);
     while ($block_count) {
         if ($block_count < 0) {
-            $reader->seek($block_count, 0);
-            next;
+            # A negative count is followed by a long block size in bytes, which
+            # lets the whole block be skipped without decoding each item. Skip

Review Comment:
   `skip_block` is written with a method-style signature (`my $class = shift; 
my ($reader, $block_content) = @_`), but the only callers 
(`skip_array`/`skip_map`) invoke it as a plain function (`skip_block($reader, 
sub {...})`). That means `$class` becomes the reader handle, `$reader` becomes 
the coderef, and the first `decode_long(..., $reader)` will attempt 
`$coderef->read(...)` and die. Making `skip_block` accept both call styles (or 
removing the implicit `$class` parameter) fixes schema-projection skipping for 
arrays/maps and avoids runtime crashes when skipping those types.



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