From 9a15297a823443b19661211293bb79e7f42a44e3 Mon Sep 17 00:00:00 2001 From: Dylan Hardison Date: Mon, 4 Jul 2016 17:36:58 -0400 Subject: Bug 1282606 - Fix TrackingFlags memory leak --- Bugzilla/Attachment.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Bugzilla/Attachment.pm') diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm index 0cdec6bf0..3b4953f64 100644 --- a/Bugzilla/Attachment.pm +++ b/Bugzilla/Attachment.pm @@ -62,6 +62,7 @@ use Bugzilla::Hook; use File::Copy; use List::Util qw(max); +use Scalar::Util qw(weaken); use Storable qw(dclone); use base qw(Bugzilla::Object); @@ -157,8 +158,12 @@ the bug object to which the attachment is attached =cut sub bug { + my ($self) = @_; require Bugzilla::Bug; - return $_[0]->{bug} //= Bugzilla::Bug->new({ id => $_[0]->bug_id, cache => 1 }); + return $self->{bug} if defined $self->{bug}; + my $bug = $self->{bug} = Bugzilla::Bug->new({ id => $_[0]->bug_id, cache => 1 }); + weaken($self->{bug}); + return $bug; } =over -- cgit v1.2.3-24-g4f1b