From 48a15ed1f16517513d0e7e1f3f1cd8be56178d28 Mon Sep 17 00:00:00 2001 From: casey langen Date: Wed, 17 Jun 2020 17:09:45 -0700 Subject: [PATCH] Fixed memory leak when interrupting fs::scanDirectory --- src/core/sdk/Filesystem.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/sdk/Filesystem.h b/src/core/sdk/Filesystem.h index 5e34d2e20..f885e18e3 100644 --- a/src/core/sdk/Filesystem.h +++ b/src/core/sdk/Filesystem.h @@ -158,6 +158,7 @@ namespace musik { namespace core { namespace sdk { namespace fs { std::string relPath8 = str::u16to8(findData.cFileName); std::string fullPath8 = path + (hasTrailingSlash ? "" : "\\") + relPath8; if (interrupt && interrupt()) { + FindClose(handle); return; } else if (findData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY) { @@ -181,6 +182,7 @@ namespace musik { namespace core { namespace sdk { namespace fs { while ((entry = readdir(dir)) != nullptr) { if (interrupt && interrupt()) { + closedir(dir); return; }