loader png: fix all memory leaks.

These were detected by asan with PicturePng example,

fixed them all.
This commit is contained in:
Hermet Park 2022-01-24 21:21:17 +09:00 committed by Hermet Park
parent 246149e91a
commit 9434923529

View file

@ -72,6 +72,7 @@ PngLoader::PngLoader()
PngLoader::~PngLoader()
{
if (freeData) free(data);
free(image);
}
@ -180,6 +181,10 @@ unique_ptr<Surface> PngLoader::bitmap()
void PngLoader::run(unsigned tid)
{
if (image) {
free(image);
image = nullptr;
}
auto width = static_cast<unsigned>(w);
auto height = static_cast<unsigned>(h);