Merge pull request #564 from lioncash/leak

file_system: Prevent resource leaks in DeleteDirectory()
This commit is contained in:
Connor McLaughlin 2020-06-24 01:31:52 +10:00 committed by GitHub
commit 84d4423719
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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