Closed
Description
Bug report
Bug summary
Reading a truncated png file can segfault the process.
Code for reproduction
from pylab import *
rcdefaults()
savefig("test.png")
buf = open("test.png", "rb").read()
open("test.png", "wb").write(buf[:20]) # truncate to first 20 bytes
imread("test.png")
Actual outcome
Fatal Python error: Segmentation fault
Current thread 0x00007f3638e8a540 (most recent call first):
File "/usr/lib/python3.6/site-packages/matplotlib/image.py", line 1298 in imread
File "/usr/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2314 in imread
File "test.py", line 6 in <module>
[1] 12789 segmentation fault (core dumped) python test.py
Expected outcome
Some exception is raised.
(To be honest I'm not fully convinced there's a much of a benefit in shipping our own png wrappers rather than, say, relying on PIL throughout.)
Matplotlib version
- Operating System: Arch Linux
- Matplotlib Version: 2.0.2 and master
- Python Version: 3.6
- Jupyter Version (if applicable): NA
- Other Libraries: NA
Metadata
Metadata
Assignees
Labels
No labels