This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #106282] Don’t crash cloning tied %^H
[perl5.git] / hv.c
diff --git a/hv.c b/hv.c
index 27ce6a5..7ce8048 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1465,7 +1465,7 @@ Perl_hv_copy_hints_hv(pTHX_ HV *const ohv)
        while ((entry = hv_iternext_flags(ohv, 0))) {
            SV *const sv = newSVsv(HeVAL(entry));
            SV *heksv = newSVhek(HeKEY_hek(entry));
-           sv_magic(sv, NULL, PERL_MAGIC_hintselem,
+           if (sv) sv_magic(sv, NULL, PERL_MAGIC_hintselem,
                     (char *)heksv, HEf_SVKEY);
            SvREFCNT_dec(heksv);
            (void)hv_store_flags(hv, HeKEY(entry), HeKLEN(entry),