diff hgext/largefiles/overrides.py @ 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 155d0f8fb7e5
children a77ce45584ef
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)