mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-15 14:51:59 +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:
|
||||
s = self.fh.read(512)
|
||||
if len(s) != 512:
|
||||
self.fh.close()
|
||||
|
||||
msg = "unexpected end of tar file"
|
||||
raise OSError(msg)
|
||||
|
||||
name = s[:100].decode("utf-8")
|
||||
i = name.find("\0")
|
||||
if i == 0:
|
||||
self.fh.close()
|
||||
|
||||
msg = "cannot find subfile"
|
||||
raise OSError(msg)
|
||||
if i > 0:
|
||||
|
|
Loading…
Reference in New Issue
Block a user