Skip to content

Instantly share code, notes, and snippets.

@Mons
Created April 25, 2015 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mons/3291306e02d3f2c6d024 to your computer and use it in GitHub Desktop.
Save Mons/3291306e02d3f2c6d024 to your computer and use it in GitHub Desktop.
CBOR::XS incr_parse die
use 5.010;
use CBOR::XS;
use Data::Dumper;
my $cbor = CBOR::XS->new();
my $data = "\x82\x01\xD9\x56\x52\x44test";
say Dumper $cbor->decode($data);
my $buf;
for (split //, $data) {
$buf .= $_;
eval {
for ($cbor->incr_parse($buf)) {
say "decoded: @$_";
}
1} or warn "Died: $@";
}
@Mons
Copy link
Author

Mons commented Apr 25, 2015

$ perl case.pl 
$VAR1 = [
          1,
          \'test'
        ];

Died: unexpected end of CBOR data, at offset 5 (octet 0x00) at case.pl line 12.
decoded: 1 SCALAR(0x242e2f0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment