diff --git a/PIL/SpiderImagePlugin.py b/PIL/SpiderImagePlugin.py index 6344a1540..0ce63002b 100644 --- a/PIL/SpiderImagePlugin.py +++ b/PIL/SpiderImagePlugin.py @@ -50,6 +50,8 @@ def isInt(f): return 0 except ValueError: return 0 + except OverflowError: + return 0 iforms = [1, 3, -11, -12, -21, -22] diff --git a/Tests/images/invalid.spider b/Tests/images/invalid.spider new file mode 100644 index 000000000..c6b024d6e Binary files /dev/null and b/Tests/images/invalid.spider differ diff --git a/Tests/test_file_spider.py b/Tests/test_file_spider.py index 1ddecd365..8bd648e78 100644 --- a/Tests/test_file_spider.py +++ b/Tests/test_file_spider.py @@ -80,6 +80,11 @@ class TestImageSpider(PillowTestCase): # Assert self.assertEqual(ret, 0) + def test_invalid_file(self): + invalid_file = "Tests/images/invalid.spider" + + self.assertRaises(IOError, lambda: Image.open(invalid_file)) + if __name__ == '__main__': unittest.main()