From: Serhiy Storchaka Date: Sat, 18 Jan 2014 14:28:08 +0000 (+0200) Subject: Issue #20244: Fixed possible file leaks when unexpected error raised in X-Git-Tag: v3.3.4rc1~44 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e413cde95f79544aefce5576ebb92d18cbf6ff2e;p=python Issue #20244: Fixed possible file leaks when unexpected error raised in tarfile open functions. --- diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 6c40cb9596..d31bc70337 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