Copilot commented on code in PR #3864:
URL: https://github.com/apache/avro/pull/3864#discussion_r3567429321
##########
lang/perl/lib/Avro/BinaryDecoder.pm:
##########
@@ -323,8 +567,11 @@ sub skip_union {
my $class = shift;
my ($schema, $reader) = @_;
my $idx = decode_long($class, undef, undef, $reader);
- my $union_schema = $schema->schemas->[$idx]
- or throw Avro::Schema::Error::Parse("union union member");
+ my $schemas = $schema->schemas;
+ if ($idx < 0 || $idx >= scalar @$schemas) {
+ throw Avro::Schema::Error::Parse("union union member");
+ }
Review Comment:
`skip_union` throws an unhelpful parse error message ("union union member")
when the union branch index is out of range. This makes malformed-input
debugging harder and is inconsistent with the more descriptive message used by
`decode_union` just below.
--
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]