From bb0a7465013642919c19cdfbcfc397ae5af048d3 Mon Sep 17 00:00:00 2001 From: yao-msft <50888816+yao-msft@users.noreply.github.com> Date: Tue, 11 Jul 2023 12:07:11 -0700 Subject: [PATCH] Explicitly close file stream on FileLogger destruction (#3424) --- src/AppInstallerCommonCore/FileLogger.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/AppInstallerCommonCore/FileLogger.cpp b/src/AppInstallerCommonCore/FileLogger.cpp index 37ff62c686..ca73083f5a 100644 --- a/src/AppInstallerCommonCore/FileLogger.cpp +++ b/src/AppInstallerCommonCore/FileLogger.cpp @@ -37,6 +37,9 @@ namespace AppInstaller::Logging FileLogger::~FileLogger() { m_stream.flush(); + // When std::ofstream is constructed from an existing File handle, it does not call fclose on destruction + // Only calling close() explicitly will close the file handle. + m_stream.close(); } std::string FileLogger::GetNameForPath(const std::filesystem::path& filePath)