svg: ensure that all allocated memory.

observed a memory leak at a corner case.
This commit is contained in:
Hermet Park 2023-12-30 17:24:56 +09:00 committed by Hermet Park
parent cf35ca3392
commit fbcfb3f865

View file

@ -3528,6 +3528,10 @@ void SvgLoader::clear(bool all)
loaderData.images.reset(); loaderData.images.reset();
if (copy) free((char*)content); if (copy) free((char*)content);
delete(root);
root = nullptr;
size = 0; size = 0;
content = nullptr; content = nullptr;
copy = false; copy = false;
@ -3751,5 +3755,7 @@ bool SvgLoader::close()
Paint* SvgLoader::paint() Paint* SvgLoader::paint()
{ {
this->done(); this->done();
return root; auto ret = root;
root = nullptr;
return ret;
} }