summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2019-03-25 17:18:58 +0000
committerDavid Mitchell <davem@iabyn.com>2019-03-25 20:32:21 +0000
commit1113f30d91f662c876a07b357666f02f04a30a75 (patch)
tree985ff5e87e004381b4fffce0e3aacf1b5310081d /mg.c
parent6256cf2c2cee30277e34d38416070f9ec671c989 (diff)
downloadperl-1113f30d91f662c876a07b357666f02f04a30a75.tar.gz
fix leak with local ${^WARNING_BITS} = ...
When restoring the old value, need to free the current value first. Can be reproduced with { local ${^WARNING_BITS} = 'swit'; } when run under ASan or similar. An equivalent test already exists in t/op/leaky-magic.t.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/mg.c b/mg.c
index b022d63442..320e2d39bb 100644
--- a/mg.c
+++ b/mg.c
@@ -2916,6 +2916,8 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
else if (strEQ(mg->mg_ptr+1, "ARNING_BITS")) {
if ( ! (PL_dowarn & G_WARN_ALL_MASK)) {
if (!SvPOK(sv)) {
+ if (!specialWARN(PL_compiling.cop_warnings))
+ PerlMemShared_free(PL_compiling.cop_warnings);
PL_compiling.cop_warnings = pWARN_STD;
break;
}