mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-24 07:08:58 +00:00
loaders: fix memory leak.
While looking for image loader, it occured memory leaks. Fixed it properly. @Issues: 178
This commit is contained in:
parent
393be38f2a
commit
932cc65543
3 changed files with 12 additions and 8 deletions
|
@ -91,10 +91,10 @@ bool LoaderMgr::term()
|
|||
|
||||
unique_ptr<Loader> LoaderMgr::loader(const string& path)
|
||||
{
|
||||
auto loader = _find(path);
|
||||
|
||||
if (loader && loader->open(path)) return unique_ptr<Loader>(loader);
|
||||
|
||||
if (auto loader = _find(path)) {
|
||||
if (loader->open(path)) return unique_ptr<Loader>(loader);
|
||||
else delete(loader);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,10 @@ unique_ptr<Loader> LoaderMgr::loader(const char* data, uint32_t size)
|
|||
{
|
||||
for (int i = 0; i < static_cast<int>(FileType::Unknown); i++) {
|
||||
auto loader = _find(static_cast<FileType>(i));
|
||||
if (loader && loader->open(data, size)) return unique_ptr<Loader>(loader);
|
||||
if (loader) {
|
||||
if (loader->open(data, size)) return unique_ptr<Loader>(loader);
|
||||
else delete(loader);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -113,7 +116,10 @@ unique_ptr<Loader> LoaderMgr::loader(uint32_t *data, uint32_t w, uint32_t h, boo
|
|||
{
|
||||
for (int i = 0; i < static_cast<int>(FileType::Unknown); i++) {
|
||||
auto loader = _find(static_cast<FileType>(i));
|
||||
if (loader && loader->open(data, w, h, copy)) return unique_ptr<Loader>(loader);
|
||||
if (loader) {
|
||||
if (loader->open(data, w, h, copy)) return unique_ptr<Loader>(loader);
|
||||
else delete(loader);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
RawLoader::RawLoader()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2427,7 +2427,6 @@ static bool _svgLoaderParserForValidCheck(void* data, SimpleXMLType type, const
|
|||
|
||||
SvgLoader::SvgLoader()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue