mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 09:26:16 +03:00
fix tiff exif loading in case when file is empty or ended
This commit is contained in:
parent
63f5f68837
commit
9930b05a33
|
@ -428,7 +428,7 @@ def _getexif(self):
|
|||
# exif field 0x8825 is an offset pointer to the location
|
||||
# of the nested embedded gps exif ifd.
|
||||
# It should be a long, but may be corrupted.
|
||||
file.seek(exif[0x8825])
|
||||
file.seek(exif[0x8825])
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
else:
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
from __future__ import division
|
||||
|
||||
import io
|
||||
import struct
|
||||
|
||||
from helper import unittest, PillowTestCase, hopper
|
||||
|
||||
from PIL import Image, TiffImagePlugin, TiffTags
|
||||
|
@ -136,6 +139,15 @@ class TestFileTiffMetadata(PillowTestCase):
|
|||
self.assertEqual(tag_ids['MakerNoteSafety'], 50741)
|
||||
self.assertEqual(tag_ids['BestQualityScale'], 50780)
|
||||
|
||||
def test_empty_metadata(self):
|
||||
f = io.BytesIO(b'II*\x00\x08\x00\x00\x00')
|
||||
head = f.read(8)
|
||||
info = TiffImagePlugin.ImageFileDirectory(head)
|
||||
try:
|
||||
self.assert_warning(UserWarning, lambda: info.load(f))
|
||||
except struct.error:
|
||||
self.fail("Should not be struct errors there.")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user