loader png external: fix potential memory leak if read fails

This commit is contained in:
Michal Maciola 2022-02-04 14:50:12 +01:00 committed by Hermet Park
parent cc173c1fb2
commit b033cfabbd

View file

@ -93,7 +93,10 @@ bool PngLoader::read()
png_image_free(image); png_image_free(image);
return false; return false;
} }
if (!png_image_finish_read(image, NULL, buffer, 0, NULL)) return false; if (!png_image_finish_read(image, NULL, buffer, 0, NULL)) {
free(buffer);
return false;
}
content = reinterpret_cast<uint32_t*>(buffer); content = reinterpret_cast<uint32_t*>(buffer);
_premultiply(reinterpret_cast<uint32_t*>(buffer), image->width, image->height); _premultiply(reinterpret_cast<uint32_t*>(buffer), image->width, image->height);