changeset 15576:e387e760b207 stable

largefiles: avoid use of uinitialized variable in case of errors
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 25 Nov 2011 02:09:48 +0100
parents 4a4a95029b31
children ad686c818e1c db286472f79f
files hgext/largefiles/overrides.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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)