mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-30 18:03:07 +03:00
Close file handle on error (#8846)
This commit is contained in:
parent
81be8d5410
commit
f673f3e543
|
@ -35,12 +35,16 @@ class TarIO(ContainerIO.ContainerIO[bytes]):
|
||||||
while True:
|
while True:
|
||||||
s = self.fh.read(512)
|
s = self.fh.read(512)
|
||||||
if len(s) != 512:
|
if len(s) != 512:
|
||||||
|
self.fh.close()
|
||||||
|
|
||||||
msg = "unexpected end of tar file"
|
msg = "unexpected end of tar file"
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
|
|
||||||
name = s[:100].decode("utf-8")
|
name = s[:100].decode("utf-8")
|
||||||
i = name.find("\0")
|
i = name.find("\0")
|
||||||
if i == 0:
|
if i == 0:
|
||||||
|
self.fh.close()
|
||||||
|
|
||||||
msg = "cannot find subfile"
|
msg = "cannot find subfile"
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
if i > 0:
|
if i > 0:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user