Improve the resilience of MAT2 wrt. corrupted PNG
This commit is contained in:
parent
759efa03ee
commit
de65f4f4d4
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user