]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1633848 - Fix possible areas where memory leak can occur in the PhabBugz daemon...
authordklawren <dklawren@users.noreply.github.com>
Wed, 29 Apr 2020 13:31:36 +0000 (09:31 -0400)
committerGitHub <noreply@github.com>
Wed, 29 Apr 2020 13:31:36 +0000 (09:31 -0400)
extensions/PhabBugz/lib/Revision.pm
extensions/PhabBugz/lib/User.pm

index e3924eefba93b1c99f926bbc445607ebbf5f1436..e2a3e5848106991aca44f73dbe9eff6ba30c00fe 100644 (file)
@@ -11,7 +11,7 @@ use 5.10.1;
 use Moo;
 
 use Mojo::JSON qw(true);
-use Scalar::Util qw(blessed);
+use Scalar::Util qw(blessed weaken);
 use Types::Standard -all;
 use Type::Utils;
 
@@ -270,7 +270,9 @@ sub update {
 
 sub _build_bug {
   my ($self) = @_;
-  return $self->{bug} ||= Bugzilla::Bug->new({id => $self->bug_id, cache => 1});
+  my $bug = $self->{bug} ||= Bugzilla::Bug->new({id => $self->bug_id, cache => 1});
+  weaken($self->{bug});
+  return $bug;
 }
 
 sub _build_author {
index 2bc2ed7dc64a7637714f24f277ccc1bacef0dcd2..3e9037ca031947c9c8fe599dd9abf8591a40ed5f 100644 (file)
@@ -15,6 +15,7 @@ use Bugzilla::Types qw(:types);
 use Bugzilla::Extension::PhabBugz::Util qw(request);
 
 use List::Util qw(first);
+use Scalar::Util qw(weaken);
 use Types::Standard -all;
 use Type::Utils;
 use Type::Params qw(compile);
@@ -158,7 +159,9 @@ sub match {
 sub _build_bugzilla_user {
   my ($self) = @_;
   return undef unless $self->bugzilla_id;
-  return Bugzilla::User->new({id => $self->bugzilla_id, cache => 1});
+  my $user = $self->{user} ||= Bugzilla::User->new({id => $self->bugzilla_id, cache => 1});
+  weaken($self->{user});
+  return $user;
 }
 
 sub get_phab_bugzilla_ids {