one more memory leak
Jesse Luehrs [Sat, 13 Nov 2010 17:48:10 +0000 (11:48 -0600)]
Stash.xs
t/20-leaks.t

index 4161ac6..9f8ee77 100644 (file)
--- a/Stash.xs
+++ b/Stash.xs
@@ -216,6 +216,7 @@ SV *_get_package_symbol(SV *self, varspec_t *variable, int vivify)
         /* can't use gv_init here, because it screws up @ISA in a way that I
          * can't reproduce, but that CMOP triggers */
         gv_fetchsv(namesv, GV_ADD, vartype_to_svtype(variable->type));
+        SvREFCNT_dec(namesv);
     }
 
     if (vivify) {
index 53989a6..caebd4f 100644 (file)
@@ -141,4 +141,16 @@ use Symbol;
     } "list_all_package_symbols doesn't leak";
 }
 
+# mimic CMOP::create_anon_class
+{
+    my $i = 0;
+    no_leaks_ok {
+        $i++;
+        eval "package Quux$i; 1;";
+        my $quux = Package::Stash->new("Quux$i");
+        $quux->get_or_add_package_symbol('@ISA');
+        delete $::{'Quux' . $i . '::'};
+    } "get_package_symbol doesn't leak during glob expansion";
+}
+
 done_testing;