diff --git a/dist/Storable/Storable.xs b/dist/Storable/Storable.xs index ed729c94a66f..6a45d8adf2f6 100644 --- a/dist/Storable/Storable.xs +++ b/dist/Storable/Storable.xs @@ -6808,8 +6808,7 @@ static SV *retrieve_regexp(pTHX_ stcxt_t *cxt, const char *cname) { SV *sv; dSP; I32 count; - - PERL_UNUSED_ARG(cname); + HV *stash; ENTER; SAVETMPS; @@ -6857,6 +6856,8 @@ static SV *retrieve_regexp(pTHX_ stcxt_t *cxt, const char *cname) { sv = SvRV(re_ref); SvREFCNT_inc(sv); + stash = cname ? gv_stashpv(cname, GV_ADD) : 0; + SEEN_NN(sv, stash, 0); FREETMPS; LEAVE; diff --git a/dist/Storable/t/regexp.t b/dist/Storable/t/regexp.t index acf28cfec666..e7c6c7e94a1a 100644 --- a/dist/Storable/t/regexp.t +++ b/dist/Storable/t/regexp.t @@ -37,7 +37,7 @@ while () { } } -plan tests => 9 + 3*scalar(@tests); +plan tests => 10 + 3*scalar(@tests); SKIP: { @@ -75,6 +75,8 @@ SKIP: ok(!eval { dclone($re) }, "should fail to clone, even with use re 'eval'"); } +is(ref(dclone(bless qr//, "Foo")), "Foo", "check reblessed regexps"); + for my $test (@tests) { my ($code, $not, $match, $matchc, $name) = @$test; my $qr = eval $code; diff --git a/dist/Storable/t/weak.t b/dist/Storable/t/weak.t index 220c70160f2b..48752fbec427 100644 --- a/dist/Storable/t/weak.t +++ b/dist/Storable/t/weak.t @@ -29,7 +29,7 @@ sub BEGIN { } use Test::More 'no_plan'; -use Storable qw (store retrieve freeze thaw nstore nfreeze); +use Storable qw (store retrieve freeze thaw nstore nfreeze dclone); require 'testlib.pl'; our $file; use strict; @@ -143,3 +143,11 @@ foreach (@tests) { $stored = nfreeze $input; tester($stored, \&freeze_and_thaw, $testsub, 'network string'); } + +{ + # [perl #134179] sv_upgrade from type 7 down to type 1 + my $foo = [qr//,[]]; + weaken($foo->[1][0][0] = $foo->[1]); + my $out = dclone($foo); # croaked here + is_deeply($out, $foo, "check they match"); +}