mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 06:15:38 +00:00
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:
parent
3ca9d578b3
commit
83a01c27a2
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue