Fixed memory leak when interrupting fs::scanDirectory

This commit is contained in:
casey langen 2020-06-17 17:09:45 -07:00
parent 6553039933
commit 48a15ed1f1

View File

@ -158,6 +158,7 @@ namespace musik { namespace core { namespace sdk { namespace fs {
std::string relPath8 = str::u16to8(findData.cFileName); std::string relPath8 = str::u16to8(findData.cFileName);
std::string fullPath8 = path + (hasTrailingSlash ? "" : "\\") + relPath8; std::string fullPath8 = path + (hasTrailingSlash ? "" : "\\") + relPath8;
if (interrupt && interrupt()) { if (interrupt && interrupt()) {
FindClose(handle);
return; return;
} }
else if (findData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY) { else if (findData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY) {
@ -181,6 +182,7 @@ namespace musik { namespace core { namespace sdk { namespace fs {
while ((entry = readdir(dir)) != nullptr) { while ((entry = readdir(dir)) != nullptr) {
if (interrupt && interrupt()) { if (interrupt && interrupt()) {
closedir(dir);
return; return;
} }