From: YAMASHINA Hio Date: Wed, 15 Oct 2008 17:34:35 +0000 (+0900) Subject: Storable.thaw segv on blessed reference to overloaded object X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6bf6381f4513c0dbdea17a4f96c82c34672ca66c;p=p5sagit%2Fp5-mst-13.2.git Storable.thaw segv on blessed reference to overloaded object Message-Id: <20081015173435.dd95b362.hio@hio.jp> p4raw-id: //depot/perl@34481 --- diff --git a/ext/Storable/Storable.xs b/ext/Storable/Storable.xs index 89e8b85..24de05f 100644 --- a/ext/Storable/Storable.xs +++ b/ext/Storable/Storable.xs @@ -4567,7 +4567,7 @@ static SV *retrieve_overloaded(pTHX_ stcxt_t *cxt, const char *cname) * WARNING: breaks RV encapsulation. */ - sv_upgrade(rv, SVt_RV); + SvUPGRADE(rv, SVt_RV); SvRV_set(rv, sv); /* $rv = \$sv */ SvROK_on(rv); diff --git a/ext/Storable/t/overload.t b/ext/Storable/t/overload.t index ceac2b0..93f0794 100644 --- a/ext/Storable/t/overload.t +++ b/ext/Storable/t/overload.t @@ -25,7 +25,7 @@ sub ok; use Storable qw(freeze thaw); -print "1..16\n"; +print "1..19\n"; package OVERLOADED; @@ -103,4 +103,17 @@ ok 13, $@ eq ""; ok 14, ref ($t) eq 'REF'; ok 15, ref ($$t) eq 'HAS_OVERLOAD'; ok 16, $$$t eq 'snow'; + + +#--- +# blessed reference to overloded object. +{ + my $a = bless [88], 'OVERLOADED'; + my $c = thaw freeze bless \$a, 'main'; + ok 17, ref $c eq 'main'; + ok 18, ref $$c eq 'OVERLOADED'; + ok 19, "$$c" eq "88"; + +} + 1;