Skip to content

Commit

Permalink
close #7; fix a memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
gfx committed Sep 29, 2013
1 parent 4ec2387 commit f378af9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions t/900_mouse_bugs/015_issue7_memleak.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use strict;
use Test::Requires qw(Test::LeakTrace);
use Test::More tests => 1;

{
package Foo;

use Mouse;

has 'bar' => (
is => 'rw',
trigger => sub { }
);
}

no_leaks_ok {
my $foo = Foo->new(bar => 'TEST');
$foo->bar('bar');
};

2 changes: 1 addition & 1 deletion xs-src/MouseAccessor.xs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ mouse_attr_set(pTHX_ SV* const self, MAGIC* const mg, SV* value){
passed to the trigger */
if(flags & MOUSEf_ATTR_HAS_TRIGGER && has_slot(self, slot)){
has_old_value = 1;
old_value = newSVsv( get_slot(self, slot) );
old_value = sv_mortalcopy( get_slot(self, slot) );
}

if(flags & MOUSEf_ATTR_HAS_TC){
Expand Down

0 comments on commit f378af9

Please sign in to comment.