file_system: Prevent resource leaks in DeleteDirectory()

We need to remember to close the search handle in the error cases.
This commit is contained in:
Lioncash 2020-06-23 06:13:51 -04:00
parent 3ca9d578b3
commit 83a01c27a2

View file

@ -1027,13 +1027,19 @@ bool FileSystem::DeleteDirectory(const char* Path, bool Recursive)
{
// recurse into that
if (!DeleteDirectory(fileName, true))
{
FindClose(hFind);
return false;
}
}
else
{
// found a file, so delete it
if (!DeleteFileA(fileName))
{
FindClose(hFind);
return false;
}
}
} while (FindNextFileA(hFind, &findData));
FindClose(hFind);