summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-01-18 14:28:08 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-01-18 14:28:08 (GMT)
commite413cde95f79544aefce5576ebb92d18cbf6ff2e (patch)
tree0f489572ee5fb28f164ea93ab7aeb219d4df7e00 /Lib/tarfile.py
parentc2d01423e02d9721f897812cf6a93e64c7d75c15 (diff)
downloadcpython-e413cde95f79544aefce5576ebb92d18cbf6ff2e.zip
cpython-e413cde95f79544aefce5576ebb92d18cbf6ff2e.tar.gz
cpython-e413cde95f79544aefce5576ebb92d18cbf6ff2e.tar.bz2
Issue #20244: Fixed possible file leaks when unexpected error raised in
tarfile open functions.
Diffstat (limited to 'Lib/tarfile.py')
-rwxr-xr-xLib/tarfile.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 6c40cb9..d31bc70 100755
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -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