1
0
mirror of synced 2024-12-27 23:21:33 +01:00

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

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: