Commit e413cde9 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #20244: Fixed possible file leaks when unexpected error raised in

tarfile open functions.
parent c2d01423
...@@ -1671,6 +1671,9 @@ class TarFile(object): ...@@ -1671,6 +1671,9 @@ class TarFile(object):
if mode == 'r': if mode == 'r':
raise ReadError("not a bzip2 file") raise ReadError("not a bzip2 file")
raise raise
except:
fileobj.close()
raise
t._extfileobj = False t._extfileobj = False
return t return t
...@@ -1696,6 +1699,9 @@ class TarFile(object): ...@@ -1696,6 +1699,9 @@ class TarFile(object):
if mode == 'r': if mode == 'r':
raise ReadError("not an lzma file") raise ReadError("not an lzma file")
raise raise
except:
fileobj.close()
raise
t._extfileobj = False t._extfileobj = False
return t return t
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment