diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-18 14:28:37 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-01-18 14:28:37 (GMT) |
commit | 2d1f0924691a214bbe6360233566b0c6241fbc47 (patch) | |
tree | c8e6179bbedbad853995bbf0cefc56c6243f1315 /Lib/tarfile.py | |
parent | aee0e63ed052ae891e4b5f342aae512787098fa4 (diff) | |
parent | e413cde95f79544aefce5576ebb92d18cbf6ff2e (diff) | |
download | cpython-2d1f0924691a214bbe6360233566b0c6241fbc47.zip cpython-2d1f0924691a214bbe6360233566b0c6241fbc47.tar.gz cpython-2d1f0924691a214bbe6360233566b0c6241fbc47.tar.bz2 |
Issue #20244: Fixed possible file leaks when unexpected error raised in
tarfile open functions.
Diffstat (limited to 'Lib/tarfile.py')
-rwxr-xr-x | Lib/tarfile.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index d914485..79566e7 100755 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1647,6 +1647,9 @@ class TarFile(object): if mode == 'r': raise ReadError("not a bzip2 file") raise + except: + fileobj.close() + raise t._extfileobj = False return t @@ -1672,6 +1675,9 @@ class TarFile(object): if mode == 'r': raise ReadError("not an lzma file") raise + except: + fileobj.close() + raise t._extfileobj = False return t |