From: Jesse Luehrs Date: Sat, 13 Nov 2010 17:48:10 +0000 (-0600) Subject: one more memory leak X-Git-Tag: 0.14~32 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=02b2a57f5ce745d7989c3fc74d054c6e1c71ee49;p=gitmo%2FPackage-Stash-XS.git one more memory leak --- diff --git a/Stash.xs b/Stash.xs index 4161ac6..9f8ee77 100644 --- 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) { diff --git a/t/20-leaks.t b/t/20-leaks.t index 53989a6..caebd4f 100644 --- a/t/20-leaks.t +++ b/t/20-leaks.t @@ -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;