fix tiff exif loading in case when file is empty or ended

This commit is contained in:
homm 2015-09-15 04:06:51 +03:00
parent 63f5f68837
commit 9930b05a33
2 changed files with 13 additions and 1 deletions

View File

@ -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()