From: Marcus Holland-Moritz Date: Sat, 2 Aug 2003 13:40:16 +0000 (+0200) Subject: Storable and uninitalized array values X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=20bb3f55e73254cd65990282983e87860e6ebfab;p=p5sagit%2Fp5-mst-13.2.git Storable and uninitalized array values From: "Marcus Holland-Moritz" Message-ID: <00ab01c358ea$d940a5b0$0c2f1fac@R2D2> p4raw-id: //depot/perl@20453 --- diff --git a/ext/Storable/Storable.xs b/ext/Storable/Storable.xs index e344700..1bf09c1 100644 --- a/ext/Storable/Storable.xs +++ b/ext/Storable/Storable.xs @@ -850,12 +850,12 @@ static const char byteorderstr_56[] = {BYTEORDER_BYTES_56, 0}; #define STORE_SCALAR(pv, len) STORE_PV_LEN(pv, len, SX_SCALAR, SX_LSCALAR) /* - * Store undef in arrays and hashes without recursing through store(). + * Store &PL_sv_undef in arrays without recursing through store(). */ -#define STORE_UNDEF() \ +#define STORE_SV_UNDEF() \ STMT_START { \ cxt->tagnum++; \ - PUTMARK(SX_UNDEF); \ + PUTMARK(SX_SV_UNDEF); \ } STMT_END /* @@ -2037,7 +2037,7 @@ static int store_array(stcxt_t *cxt, AV *av) sav = av_fetch(av, i, 0); if (!sav) { TRACEME(("(#%d) undef item", i)); - STORE_UNDEF(); + STORE_SV_UNDEF(); continue; } TRACEME(("(#%d) item", i)); diff --git a/ext/Storable/t/freeze.t b/ext/Storable/t/freeze.t index de13af6..bf557df 100644 --- a/ext/Storable/t/freeze.t +++ b/ext/Storable/t/freeze.t @@ -24,7 +24,7 @@ sub BEGIN { use Storable qw(freeze nfreeze thaw); -print "1..19\n"; +print "1..20\n"; $a = 'toto'; $b = \$a; @@ -136,3 +136,9 @@ ok 18, !$@; thaw $frozen; # used to segfault here ok 19, 1; + +$a = []; $#$a = 2; $a->[1] = undef; +$b = thaw freeze $a; +@a = map { ~~ exists $a->[$_] } 0 .. $#$a; +@b = map { ~~ exists $b->[$_] } 0 .. $#$b; +ok 20, "@a" eq "@b";