summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sv.c2
-rw-r--r--t/op/ref.t11
2 files changed, 12 insertions, 1 deletions
diff --git a/sv.c b/sv.c
index 5ee48175b2..3efbc39ea7 100644
--- a/sv.c
+++ b/sv.c
@@ -4613,6 +4613,7 @@ Perl_sv_sethek(pTHX_ register SV *const sv, const HEK *const hek)
sv_setpvn(sv, HEK_KEY(hek), HEK_LEN(hek));
if (HEK_UTF8(hek))
SvUTF8_on(sv);
+ else SvUTF8_off(sv);
return;
}
{
@@ -4624,6 +4625,7 @@ Perl_sv_sethek(pTHX_ register SV *const sv, const HEK *const hek)
SvPOK_on(sv);
if (HEK_UTF8(hek))
SvUTF8_on(sv);
+ else SvUTF8_off(sv);
return;
}
}
diff --git a/t/op/ref.t b/t/op/ref.t
index 36371f7b73..e2ba10fca2 100644
--- a/t/op/ref.t
+++ b/t/op/ref.t
@@ -8,7 +8,7 @@ BEGIN {
use strict qw(refs subs);
-plan(223);
+plan(224);
# Test glob operations.
@@ -208,6 +208,15 @@ is (ref *STDOUT{IO}, 'IO::File', 'IO refs are blessed into IO::File');
like (*STDOUT{IO}, qr/^IO::File=IO\(0x[0-9a-f]+\)$/,
'stringify for IO refs');
+{ # Test re-use of ref's TARG [perl #101738]
+ my $obj = bless [], '____';
+ my $uniobj = bless [], chr 256;
+ my $get_ref = sub { ref shift };
+ my $dummy = &$get_ref($uniobj);
+ $dummy = &$get_ref($obj);
+ ok exists { ____ => undef }->{$dummy}, 'ref sets UTF8 flag correctly';
+}
+
# Test anonymous hash syntax.
$anonhash = {};