Subject: | Data::Plist::BinaryWriter write_fh doesn't handle large object graphs |
Date: | Tue, 03 Jan 2012 15:34:25 -0800 |
To: | bug-Data-Plist [...] rt.cpan.org |
From: | eoin <eoin [...] apple.com> |
The BinaryWriter doesn't handle more than 65535 object, although the plist file format does.
The simple change is below:
sub write_fh_big {
my $self = shift;
$self = $self->new() unless ref $self;
my ( $fh, $object ) = @_;
$object = $self->serialize($object) if ( $self->{serialize} );
binmode $fh;
$self->{fh} = $fh;
$self->{index} = [];
$self->{size} = $self->count($object);
$self->{objcache} = {};
if ( $self->{size} >= 4**8 ) { # this is the patch
$self->{refsize} = 4; # this is the patch
} elsif ( $self->{size} >= 2**8 ) {
$self->{refsize} = 2;
} else {
$self->{refsize} = 1;
}
Thanks!
-Eoin