@@ -3888,7 +3888,7 @@ S_apply_attrs(pTHX_ HV *stash, SV *target, OP *attrs)
3888
3888
3889
3889
Perl_load_module(
3890
3890
aTHX_ PERL_LOADMOD_IMPORT_OPS,
3891
- newSVpvs (ATTRSMODULE),
3891
+ newSVpvs_share (ATTRSMODULE),
3892
3892
NULL,
3893
3893
op_prepend_elem(OP_LIST,
3894
3894
newSVOP(OP_CONST, 0, stashsv),
@@ -3903,7 +3903,7 @@ STATIC void
3903
3903
S_apply_attrs_my(pTHX_ HV *stash, OP *target, OP *attrs, OP **imopsp)
3904
3904
{
3905
3905
OP *pack, *imop, *arg;
3906
- SV *meth, *stashsv, **svp;
3906
+ SV *meth, *stashsv, *attrpkg, * *svp;
3907
3907
3908
3908
PERL_ARGS_ASSERT_APPLY_ATTRS_MY;
3909
3909
@@ -3914,17 +3914,23 @@ S_apply_attrs_my(pTHX_ HV *stash, OP *target, OP *attrs, OP **imopsp)
3914
3914
target->op_type == OP_PADHV ||
3915
3915
target->op_type == OP_PADAV);
3916
3916
3917
+ attrpkg = newSVpvs_share(ATTRSMODULE);
3918
+ /* no sv_2mortal() or its freed by time of leave_scope() -> replace_sv() */
3919
+ SAVEFREESV(attrpkg);
3920
+
3917
3921
/* Ensure that attributes.pm is loaded. */
3918
3922
/* Don't force the C<use> if we don't need it. */
3919
3923
svp = hv_fetchs(GvHVn(PL_incgv), ATTRSMODULE_PM, FALSE);
3920
3924
if (svp && *svp != &PL_sv_undef)
3921
3925
NOOP; /* already in %INC */
3922
- else
3923
- Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT,
3924
- newSVpvs(ATTRSMODULE), NULL);
3926
+ else {
3927
+ SvREFCNT_inc_simple_void_NN(attrpkg);
3928
+ Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, attrpkg, NULL);
3929
+ }
3925
3930
3926
3931
/* Need package name for method call. */
3927
- pack = newSVOP(OP_CONST, 0, newSVpvs(ATTRSMODULE));
3932
+ SvREFCNT_inc_simple_void_NN(attrpkg);
3933
+ pack = newSVOP(OP_CONST, 0, attrpkg);
3928
3934
3929
3935
/* Build up the real arg-list. */
3930
3936
stashsv = newSVhek(HvNAME_HEK(stash));
@@ -3989,7 +3995,7 @@ Perl_apply_attrs_string(pTHX_ const char *stashpv, CV *cv,
3989
3995
}
3990
3996
3991
3997
Perl_load_module(aTHX_ PERL_LOADMOD_IMPORT_OPS,
3992
- newSVpvs (ATTRSMODULE),
3998
+ newSVpvs_share (ATTRSMODULE),
3993
3999
NULL, op_prepend_elem(OP_LIST,
3994
4000
newSVOP(OP_CONST, 0, newSVpv(stashpv,0)),
3995
4001
op_prepend_elem(OP_LIST,
0 commit comments