Patchwork [1,of,4] convert: fix a file descriptor leak

login
register
mail settings
Submitter Matt Harbison
Date Sept. 26, 2018, 4:06 a.m.
Message ID <9403d51284f4cab9b143.1537934761@Envy>
Download mbox | patch
Permalink /patch/35038/
State Accepted
Headers show

Comments

Matt Harbison - Sept. 26, 2018, 4:06 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1537929978 14400
#      Tue Sep 25 22:46:18 2018 -0400
# Node ID 9403d51284f4cab9b143612157c747fe13382c5b
# Parent  7a9e2d85f475b1675da537ece26419887f9d8b4e
convert: fix a file descriptor leak

test-check-code flagged this after I changed this line for something unrelated.
Yuya Nishihara - Sept. 26, 2018, 11:38 a.m.
On Wed, 26 Sep 2018 00:06:01 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1537929978 14400
> #      Tue Sep 25 22:46:18 2018 -0400
> # Node ID 9403d51284f4cab9b143612157c747fe13382c5b
> # Parent  7a9e2d85f475b1675da537ece26419887f9d8b4e
> convert: fix a file descriptor leak

Queued these, thanks.

Patch

diff --git a/hgext/convert/gnuarch.py b/hgext/convert/gnuarch.py
--- a/hgext/convert/gnuarch.py
+++ b/hgext/convert/gnuarch.py
@@ -18,6 +18,7 @@  from mercurial import (
     encoding,
     error,
     pycompat,
+    util,
 )
 from mercurial.utils import (
     dateutil,
@@ -228,7 +229,7 @@  class gnuarch_source(common.converter_so
             else:
                 mode = ''
         else:
-            data = open(os.path.join(self.tmppath, name), 'rb').read()
+            data = util.readfile(os.path.join(self.tmppath, name))
             mode = (mode & 0o111) and 'x' or ''
         return data, mode