From d3a58e043a804feacc1d401dd4e1be02c56fc93d Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Sun, 11 Sep 2016 10:10:35 -0400 Subject: Bug 1301951 - Fix Bugzilla::Bug memory leaks --- Bugzilla/Comment.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Bugzilla/Comment.pm') diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm index d995d4509..2f063934a 100644 --- a/Bugzilla/Comment.pm +++ b/Bugzilla/Comment.pm @@ -21,7 +21,7 @@ use Bugzilla::User; use Bugzilla::Util; use List::Util qw(first); -use Scalar::Util qw(blessed); +use Scalar::Util qw(blessed weaken isweak); ############################### #### Initialization #### @@ -232,8 +232,11 @@ sub collapsed { sub bug { my $self = shift; require Bugzilla::Bug; - $self->{bug} ||= new Bugzilla::Bug($self->bug_id); - return $self->{bug}; + + # note $bug exists as a strong reference to keep $self->{bug} defined until the end of this method + my $bug = $self->{bug} ||= new Bugzilla::Bug($self->bug_id); + weaken($self->{bug}) unless isweak($self->{bug}); + return $bug; } sub is_about_attachment { -- cgit v1.2.3-24-g4f1b