develooper Front page | perl.perl5.porters | Postings from June 2013

[perl #118551] Storable hooks silently convert '' to undef

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
June 20, 2013 23:40
Subject:
[perl #118551] Storable hooks silently convert '' to undef
Message ID:
rt-3.6.HEAD-2552-1371771589-1564.118551-15-0@perl.org
On Thu Jun 20 09:31:42 2013, Michael.Jacob3@de.ibm.com wrote:
> This is a bug report for perl from DE113631@BROADBRICK,
> generated with the help of perlbug 1.39 running under perl 5.10.1.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> 
> If the serialized form returned by STORABLE_freeze() is the empty
> string
> STORABLE_thaw()/_attach() will be fed undef instead.
> 
> (This may be intended but not documented.)
> 
> package xyz;
> 
> use Storable qw(freeze thaw);
> 
> sub new {
>         my $class = shift;
>         my $string = shift;
>         die 'Bad data' unless defined $string;
>         my $self = { string => $string };
>         return bless $self, $class;
> }
> 
> sub STORABLE_freeze {
>         my $self = shift;
>         my $cloning = shift;
>         return if $cloning;
>         return ($self->{string});
> }
> 
> sub STORABLE_attach {
>         my $class = shift;
>         my $cloning = shift;
>         my $string = shift;
>         return $class->new($string);
> }
> 
> print $Storable::VERSION, "\n"; # 2.39
> 
> $a = [ xyz->new('a'), xyz->new('') ];
> 
> $b = freeze($a);
> 
> thaw($b); # <-- dies here with "Bad data"
> 

I can confirm that this also occurs with blead and Storable 2.43.



---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=118551

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About