diff options
author | Gisle Aas <gisle@aas.no> | 2005-11-27 20:48:18 -0800 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-12-02 10:37:05 +0000 |
commit | d4aa20cb0487595042985e789c92bdecea536422 (patch) | |
tree | 7d601b762c972d204593b4840bf9bd78774e0c6d /ext | |
parent | 2d3e09341b1708b9d4e0982daf4d89d075ef0973 (diff) | |
download | perl-d4aa20cb0487595042985e789c92bdecea536422.tar.gz |
Storable retrieve_lscalar fails for empty strings [PATCH]
Message-ID: <lr3blhndkd.fsf@caliper.activestate.com>
and
Message-ID: <lrwtisn062.fsf@caliper.activestate.com>
p4raw-id: //depot/perl@26243
Diffstat (limited to 'ext')
-rw-r--r-- | ext/Storable/Storable.xs | 5 | ||||
-rw-r--r-- | ext/Storable/t/malice.t | 8 |
2 files changed, 12 insertions, 1 deletions
diff --git a/ext/Storable/Storable.xs b/ext/Storable/Storable.xs index c63087d2cf..86ac2c6a55 100644 --- a/ext/Storable/Storable.xs +++ b/ext/Storable/Storable.xs @@ -4767,6 +4767,11 @@ static SV *retrieve_lscalar(pTHX_ stcxt_t *cxt, const char *cname) sv = NEWSV(10002, len); SEEN(sv, cname, 0); /* Associate this new scalar with tag "tagnum" */ + if (len == 0) { + sv_setpvn(sv, "", 0); + return sv; + } + /* * WARNING: duplicates parts of sv_setpv and breaks SV data encapsulation. * diff --git a/ext/Storable/t/malice.t b/ext/Storable/t/malice.t index 703ce47bd6..648b15f687 100644 --- a/ext/Storable/t/malice.t +++ b/ext/Storable/t/malice.t @@ -51,7 +51,7 @@ use Test::More; # present in files, but not in things store()ed to memory $fancy = ($] > 5.007 ? 2 : 0); -plan tests => 368 + length ($byteorder) * 4 + $fancy * 8 + 1; +plan tests => 372 + length ($byteorder) * 4 + $fancy * 8; use Storable qw (store retrieve freeze thaw nstore nfreeze); require 'testlib.pl'; @@ -306,3 +306,9 @@ test_things($stored, \&freeze_and_thaw, 'string', 1); # us, which will probably alert the user that something went wrong. ok(1); } + +# Unusual in that the empty string is stored with an SX_LSCALAR marker +my $hash = store_and_retrieve("pst0\5\6\3\0\0\0\1\1\0\0\0\0\0\0\0\5empty"); +ok(!$@, "no exception"); +is(ref($hash), "HASH", "got a hash"); +is($hash->{empty}, "", "got empty element"); |