1
0
mirror of synced 2024-11-25 10:44:23 +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): def __init__(self, filename):
super().__init__(filename) super().__init__(filename)
if imghdr.what(filename) != 'png':
raise ValueError
try: # better fail here than later try: # better fail here than later
cairo.ImageSurface.create_from_png(self.filename) cairo.ImageSurface.create_from_png(self.filename)
except MemoryError: except MemoryError: