Skip to content

Commit

Permalink
Close the file pointer copy (_fp) in the libtiff encoder if it is sti…
Browse files Browse the repository at this point in the history
…ll open.
  • Loading branch information
Frédéric Carron committed Mar 3, 2023
1 parent 01520de commit 2299490
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/PIL/TiffImagePlugin.py
Expand Up @@ -1850,6 +1850,11 @@ def _save(im, fp, filename):
fp.write(data)
if errcode:
break
if _fp:
try:
os.close(_fp)
except OSError:
pass
if errcode < 0:
msg = f"encoder error {errcode} when writing image file"
raise OSError(msg)
Expand Down

0 comments on commit 2299490

Please sign in to comment.