summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2003-12-06 16:30:35 +0000
committerNicholas Clark <nick@ccl4.org>2003-12-06 16:30:35 +0000
commit5c98da1c029548d157089bc95672bf854902dd76 (patch)
tree462f66bb4b177c641af64a7ba3a4b7b55a7e645e /sv.c
parenta50f9722cb036c30107aa1792c3d52462a4218f5 (diff)
downloadperl-5c98da1c029548d157089bc95672bf854902dd76.tar.gz
Make sv_force_normal_flags cope with shared hash key scalars
(remember the pointer from SvPVX, reset the flags before SvGROW, avoid crazy loops or read-from-free) p4raw-id: //depot/perl@21854
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sv.c b/sv.c
index 5e61449761..dc089b8386 100644
--- a/sv.c
+++ b/sv.c
@@ -4497,14 +4497,17 @@ Perl_sv_force_normal_flags(pTHX_ register SV *sv, U32 flags)
if (SvREADONLY(sv)) {
if (SvFAKE(sv)) {
char *pvx = SvPVX(sv);
+ int is_utf8 = SvUTF8(sv);
STRLEN len = SvCUR(sv);
U32 hash = SvUVX(sv);
SvFAKE_off(sv);
SvREADONLY_off(sv);
+ SvPVX(sv) = 0;
+ SvLEN(sv) = 0;
SvGROW(sv, len + 1);
Move(pvx,SvPVX(sv),len,char);
*SvEND(sv) = '\0';
- unsharepvn(pvx, SvUTF8(sv) ? -(I32)len : len, hash);
+ unsharepvn(pvx, is_utf8 ? -(I32)len : len, hash);
}
else if (IN_PERL_RUNTIME)
Perl_croak(aTHX_ PL_no_modify);