1
0
Fork 0

Improve the resilience of MAT2 wrt. corrupted PNG

This commit is contained in:
jvoisin 2018-09-09 19:09:05 +02:00
parent 759efa03ee
commit de65f4f4d4
1 changed files with 4 additions and 0 deletions

View File

@ -62,6 +62,10 @@ class PNGParser(_ImageParser):
def __init__(self, filename):
super().__init__(filename)
if imghdr.what(filename) != 'png':
raise ValueError
try: # better fail here than later
cairo.ImageSurface.create_from_png(self.filename)
except MemoryError: