This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix a memory leak in sv_sethek(), amending 70b71ec84
[perl5.git] / sv.c
diff --git a/sv.c b/sv.c
index 1bccaae..b0eaf92 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -4553,6 +4553,7 @@ Perl_sv_sethek(pTHX_ register SV *const sv, const HEK *const hek)
         {
            SV_CHECK_THINKFIRST_COW_DROP(sv);
            SvUPGRADE(sv, SVt_PV);
+           Safefree(SvPVX(sv));
            SvPV_set(sv,(char *)HEK_KEY(share_hek_hek(hek)));
            SvCUR_set(sv, HEK_LEN(hek));
            SvLEN_set(sv, 0);