Skip to content

Commit

Permalink
fix typo in exception, add more bit check
Browse files Browse the repository at this point in the history
  • Loading branch information
peczenyj committed Dec 11, 2023
1 parent 3d0ce8e commit 96f2c6a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/GDPR/IAB/TCFv2/BitUtils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ our @EXPORT_OK = qw<is_set
sub is_set {
my ( $data, $offset ) = @_;

croak "index our of bounds on offset $offset" if $offset >= length($data);
croak "index out of bounds on offset $offset"
if $offset + 1 > length($data);

my $r = substr( $data, $offset, 1 ) == 1;

Expand Down Expand Up @@ -151,6 +152,9 @@ sub _get_bits_with_padding {
sub _add_padding {
my ( $data, $bits, $offset, $nbits ) = @_;

croak "index out of bounds on offset $offset"
if $offset + $nbits > length($data);

my $padding = "0" x ( $bits - $nbits );

my $r = $padding . substr( $data, $offset, $nbits );
Expand Down

0 comments on commit 96f2c6a

Please sign in to comment.