Fix Dave's original shared hash key corruption bug
Nicholas Clark [Sun, 7 Mar 2004 23:31:49 +0000 (23:31 +0000)]
p4raw-id: //depot/perl@22465

sv.c

diff --git a/sv.c b/sv.c
index e49ac5e..ad9c33a 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3570,6 +3570,12 @@ void
 Perl_sv_utf8_encode(pTHX_ register SV *sv)
 {
     (void) sv_utf8_upgrade(sv);
+    if (SvIsCOW(sv)) {
+        sv_force_normal_flags(sv, 0);
+    }
+    if (SvREADONLY(sv)) {
+       Perl_croak(aTHX_ PL_no_modify);
+    }
     SvUTF8_off(sv);
 }