mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-17 02:09:17 +01:00
Fix potential memory leaks
This commit is contained in:
parent
096ef0c94a
commit
ec443161af
@ -128,7 +128,9 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return load(stream);
|
auto res = load(stream);
|
||||||
|
stream.close();
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
@ -76,6 +76,7 @@ std::optional<PluginData> PluginDataFactory::load(const std::string &filename, M
|
|||||||
// reading into a 0x40 aligned buffer increases reading speed.
|
// reading into a 0x40 aligned buffer increases reading speed.
|
||||||
char *data = (char *) memalign(0x40, length);
|
char *data = (char *) memalign(0x40, length);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
is.close();
|
||||||
DEBUG_FUNCTION_LINE("Failed to alloc memory for holding the plugin");
|
DEBUG_FUNCTION_LINE("Failed to alloc memory for holding the plugin");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -85,6 +86,7 @@ std::optional<PluginData> PluginDataFactory::load(const std::string &filename, M
|
|||||||
result.resize(length);
|
result.resize(length);
|
||||||
memcpy(&result[0], data, length);
|
memcpy(&result[0], data, length);
|
||||||
free(data);
|
free(data);
|
||||||
|
is.close();
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Loaded file!");
|
DEBUG_FUNCTION_LINE("Loaded file!");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user