Change 27779 failed to free() memory in two places in Perl_magic_set(),
Nicholas Clark [Fri, 27 Oct 2006 21:40:40 +0000 (21:40 +0000)]
and hence was leaking like the proverbial Jumblie maritime craft.

p4raw-id: //depot/perl@29127

mg.c

diff --git a/mg.c b/mg.c
index 7c19c7e..425190b 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -2304,11 +2304,16 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
                        accumulate |= ptr[i] ;
                        any_fatals |= (ptr[i] & 0xAA) ;
                    }
-                   if (!accumulate)
-                       PL_compiling.cop_warnings = pWARN_NONE;
+                   if (!accumulate) {
+                       if (!specialWARN(PL_compiling.cop_warnings))
+                           PerlMemShared_free(PL_compiling.cop_warnings);
+                       PL_compiling.cop_warnings = pWARN_NONE;
+                   }
                    /* Yuck. I can't see how to abstract this:  */
                    else if (isWARN_on(((STRLEN *)SvPV_nolen_const(sv)) - 1,
                                       WARN_ALL) && !any_fatals) {
+                       if (!specialWARN(PL_compiling.cop_warnings))
+                           PerlMemShared_free(PL_compiling.cop_warnings);
                        PL_compiling.cop_warnings = pWARN_ALL;
                        PL_dowarn |= G_WARN_ONCE ;
                    }