]> granicus.if.org Git - python/commitdiff
Issue #20244: Fixed possible file leaks when unexpected error raised in
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 18 Jan 2014 14:28:08 +0000 (16:28 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 18 Jan 2014 14:28:08 +0000 (16:28 +0200)
tarfile open functions.

Lib/tarfile.py

index 6c40cb95964f7759bcf385dd9b1bd0aabf15df65..d31bc70337ab4b6433bb6321a0118b57c9ef6be6 100755 (executable)
@@ -1671,6 +1671,9 @@ class TarFile(object):
             if mode == 'r':
                 raise ReadError("not a bzip2 file")
             raise
+        except:
+            fileobj.close()
+            raise
         t._extfileobj = False
         return t
 
@@ -1696,6 +1699,9 @@ class TarFile(object):
             if mode == 'r':
                 raise ReadError("not an lzma file")
             raise
+        except:
+            fileobj.close()
+            raise
         t._extfileobj = False
         return t