Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ Richard Foley <richard.foley@rfi.net> <richard.foley@ubs.com>
Richard Foley <richard.foley@rfi.net> <richard.foley@ubsw.com>
Richard L. Maus, Jr. <rmaus@monmouth.com> Richard L. Maus <rmaus@monmouth.com>
Richard Leach <rich+perl@hyphen-dash-hyphen.info> Richard Leach <richardleach@users.noreply.github.com>
Richard Leach <rich+perl@hyphen-dash-hyphen.info> richardleach <richardleach@users.noreply.github.com>
Richard Soderberg <p5-authors@crystalflame.net> <perl@crystalflame.net>
Richard Soderberg <p5-authors@crystalflame.net> <rs@crystalflame.net>
Richard Soderberg <p5-authors@crystalflame.net> <rs@oregonnet.com>
Expand Down
4 changes: 4 additions & 0 deletions sv.c
Original file line number Diff line number Diff line change
Expand Up @@ -5046,6 +5046,10 @@ S_newSVsv_flags_NN_PVxx(pTHX_ SV* dsv, SV* ssv, const I32 flags)
SvNV_set(dsv, SvNVX(ssv));
break;
case SVf_ROK: /* [ 3% ]*/
/* Another corner case here. SVf_IVisUV and SVprv_WEAKREF
* have the same underlying value. We do not want to
* propagate the latter. */
SvFLAGS(dsv) &= ~SVprv_WEAKREF;
SvRV_set(dsv, SvREFCNT_inc(SvRV(ssv)));
return dsv;
default: /* [ 2% ]*/
Expand Down
32 changes: 31 additions & 1 deletion t/op/svflags.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BEGIN {
# Tests the new documented mechanism for determining the original type
# of an SV.

plan tests => 16;
plan tests => 22;
use strict;
use B qw(svref_2object SVf_IOK SVf_NOK SVf_POK);

Expand Down Expand Up @@ -83,3 +83,33 @@ is($xobj->FLAGS & (SVf_IOK | SVf_POK), SVf_POK, "correct base flags on PV");
$y = $x + 10;

is($xobj->FLAGS & (SVf_IOK | SVf_POK), (SVf_IOK | SVf_POK), "POK still set on PV used as number");


# GH #23637, GH #23646 - newSVsv_flags_NN erroneously copied WEAKREF in *some* code paths

my $ref = [];
my ($wref, $cref);

# Weakened reference SV is an SVt_IV
$wref = $ref;
builtin::weaken($wref);
ok(builtin::is_weak($wref), 'a weakened SVt_IV ref has WEAKREF set');
$cref = [ $wref ];
ok(!builtin::is_weak( $cref->[0] ), 'SVt_IV copies do NOT have WEAKREF set');

# Weakened reference SV is an SVt_PV
$wref = 'blip';
$wref = $ref;
builtin::weaken($wref);
ok(builtin::is_weak($wref), 'a weakened SVt_PV ref has WEAKREF set');
$cref = [ $wref ];
ok(!builtin::is_weak( $cref->[0] ), 'SVt_PV copies do NOT have WEAKREF set');

# Weakened reference SV is an SVt_PVIV
$wref = 1;
$wref = $ref;
builtin::weaken($wref);
ok(builtin::is_weak($wref), 'a weakened SVt_PVIV ref has WEAKREF set');
$cref = [ $wref ];
ok(!builtin::is_weak( $cref->[0] ), 'SVt_PVIV copies do NOT have WEAKREF set');

Loading