Fix crash on loading invalid PNG files
(Just a divide by zero)
This commit is contained in:
parent
d8048863e8
commit
97ba0292d6
1 changed files with 2 additions and 0 deletions
|
@ -816,6 +816,8 @@ void decoder::decode_png(std::istream& stream)
|
|||
std::vector<uint32_t> ndata;
|
||||
std::vector<uint32_t> npalette;
|
||||
ndata.resize(hdr.width * hdr.height);
|
||||
if(hdr.width == 0 || hdr.height == 0)
|
||||
throw std::runtime_error("PNG file has zero width or height");
|
||||
if(ndata.size() / hdr.width != hdr.height)
|
||||
throw std::bad_alloc();
|
||||
if(hdr.type == 3) {
|
||||
|
|
Loading…
Add table
Reference in a new issue