summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-04-12 22:45:12 +0000
committerNicholas Clark <nick@ccl4.org>2006-04-12 22:45:12 +0000
commit72dc9ed5af65c946f73050becea29207a1af86c1 (patch)
tree77d02ca4340063d7184142085f9527f83a40992e /mg.c
parentaa283a383ef6540d57dd786b93d8ba9bd303e3e6 (diff)
downloadperl-72dc9ed5af65c946f73050becea29207a1af86c1.tar.gz
Change cop_warnings from an SV holding the warnings bitmask to a
directly (shared) malloc()ed buffer holding the warnings bitmask. This avoids bugs/crashes when the interpreter that created an optree is freed but the optree remains in use by other interpreters. p4raw-id: //depot/perl@27779
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/mg.c b/mg.c
index c0ebd1b6a5..19219026f5 100644
--- a/mg.c
+++ b/mg.c
@@ -826,7 +826,8 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
}
}
else {
- sv_setsv(sv, PL_compiling.cop_warnings);
+ sv_setpvn(sv, (char *) (PL_compiling.cop_warnings + 1),
+ *PL_compiling.cop_warnings);
}
SvPOK_only(sv);
}
@@ -2274,15 +2275,20 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
}
if (!accumulate)
PL_compiling.cop_warnings = pWARN_NONE;
- else if (isWARN_on(sv, WARN_ALL) && !any_fatals) {
+ /* Yuck. I can't see how to abstract this: */
+ else if (isWARN_on(((STRLEN *)SvPV_nolen_const(sv)) - 1,
+ WARN_ALL) && !any_fatals) {
PL_compiling.cop_warnings = pWARN_ALL;
PL_dowarn |= G_WARN_ONCE ;
}
else {
- if (specialWARN(PL_compiling.cop_warnings))
- PL_compiling.cop_warnings = newSVsv(sv) ;
- else
- sv_setsv(PL_compiling.cop_warnings, sv);
+ STRLEN len;
+ const char *const p = SvPV_const(sv, len);
+
+ PL_compiling.cop_warnings
+ = Perl_new_warnings_bitfield(PL_compiling.cop_warnings,
+ p, len);
+
if (isWARN_on(PL_compiling.cop_warnings, WARN_ONCE))
PL_dowarn |= G_WARN_ONCE ;
}