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