develooper Front page | perl.perl5.porters | Postings from November 2005

Storable retrieve_lscalar fails for empty strings [PATCH]

Thread Next
From:
Gisle Aas
Date:
November 28, 2005 04:48
Subject:
Storable retrieve_lscalar fails for empty strings [PATCH]
Message ID:
lr3blhndkd.fsf@caliper.activestate.com
I got this failure when trying to retrieve a v0.1 image:

  Assertion ((sv)->sv_flags & 0xff) >= SVt_PV failed: file "Storable.xs", line 4781 at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/_retrieve.al) line 378

Problem is that retrieve_lscalar assumes that the SV it creates is
upgraded to an SVt_PV, but this does not happen when the length it
reads is 0.  This failure is not seen in the normal test suite because
current versions of Storable will always store empty strings using the
SX_SCALAR type marker.

The following patch fixes this problem.

--- ext/Storable/Storable.xs.orig	2005-11-14 11:43:07.000000000 +0100
+++ ext/Storable/Storable.xs	2005-11-28 13:38:59.000000000 +0100
@@ -4767,6 +4767,11 @@
 	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.
 	 *

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