largefiles: avoid use of uinitialized variable in case of errors stable
authorMads Kiilerich <mads@kiilerich.com>
Fri, 25 Nov 2011 02:09:48 +0100
branchstable
changeset 15576 e387e760b207
parent 15575 4a4a95029b31
child 15577 ad686c818e1c
child 15592 db286472f79f
largefiles: avoid use of uinitialized variable in case of errors
hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Fri Nov 25 02:09:45 2011 +0100
+++ b/hgext/largefiles/overrides.py	Fri Nov 25 02:09:48 2011 +0100
@@ -619,11 +619,13 @@
             f = lfutil.splitstandin(f)
 
             def getdatafn():
+                fd = None
                 try:
                     fd = open(path, 'rb')
                     return fd.read()
                 finally:
-                    fd.close()
+                    if fd:
+                        fd.close()
 
             getdata = getdatafn
         write(f, 'x' in ff and 0755 or 0644, 'l' in ff, getdata)