1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-28 15:38:30 +02:00

Free loaded file in editorclass::getLevelMetadata()

This fixes memory leaking every single time a file gets loaded(!) when
the list of custom levels gets loaded(!!!), which Valgrind reports. This
memory leak is completely my bad; 2.2 properly frees the loaded file,
and VCE uses an std::unique_ptr - which I decided to ignore and not
think about why it would be there.

It's safe to do this free after uMem gets copied into std::string;
although, in the future, I *am* thinking about refactoring this function
(and the tag finder function) to not use std::strings, and I'll have to
be careful to make sure that the memory management with the file is
correct when I do so.
This commit is contained in:
Misa 2021-02-15 19:11:51 -08:00 committed by Ethan Lee
parent 16fef54ae1
commit 3226d4f312

View File

@ -247,6 +247,8 @@ bool editorclass::getLevelMetaData(std::string& _path, LevelMetaData& _data )
std::string buf((char*) uMem);
FILESYSTEM_freeMemory(&uMem);
if (find_metadata(buf) == "")
{
printf("Couldn't load metadata for %s\n", _path.c_str());