[PATCHv1,1/1] git-p4: avoid leak of file handle when cloning
diff mbox series

Message ID 20200130115034.6191-2-luke@diamand.org
State New
Headers show
Series
  • git-p4: fix file descriptor leak
Related show

Commit Message

Luke Diamand Jan. 30, 2020, 11:50 a.m. UTC
Spotted by Eric Sunshine:

    https://public-inbox.org/git/CAPig+cRx3hG64nuDie69o_gdX39F=sR6D8LyA7J1rCErgu0aMA@mail.gmail.com/

Signed-off-by: Luke Diamand <luke@diamand.org>
---
 git-p4.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Junio C Hamano Jan. 30, 2020, 8:22 p.m. UTC | #1
Luke Diamand <luke@diamand.org> writes:

> Spotted by Eric Sunshine:
>
>     https://public-inbox.org/git/CAPig+cRx3hG64nuDie69o_gdX39F=sR6D8LyA7J1rCErgu0aMA@mail.gmail.com/
>
> Signed-off-by: Luke Diamand <luke@diamand.org>
> ---
>  git-p4.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/git-p4.py b/git-p4.py
> index eb5bc28cf9..9a71a6690d 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -3563,7 +3563,8 @@ def importRevisions(self, args, branch_arg_given):
>          changes = []
>  
>          if len(self.changesFile) > 0:
> -            output = open(self.changesFile).readlines()
> +            with open(self.changesFile) as f:
> +                output = f.readlines()
>              changeSet = set()
>              for line in output:
>                  changeSet.add(int(line))

I was scratching my head until I realized that this is PATCH 7/6 of
the other 6-patch series.

Will queue together with the other ones.  Thanks.

Patch
diff mbox series

diff --git a/git-p4.py b/git-p4.py
index eb5bc28cf9..9a71a6690d 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -3563,7 +3563,8 @@  def importRevisions(self, args, branch_arg_given):
         changes = []
 
         if len(self.changesFile) > 0:
-            output = open(self.changesFile).readlines()
+            with open(self.changesFile) as f:
+                output = f.readlines()
             changeSet = set()
             for line in output:
                 changeSet.add(int(line))