From f463686b9621b8c744e2dcb0d018ad507716d499 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Tue, 12 Sep 2023 08:03:46 -0400 Subject: Make sure error logging or destructors don't throw exception when trying to get file name from handle (#393) - Bugfix: Make sure error logging or destructors don't throw exception when trying to get file name from handle --- src/zenutil/basicfile.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/zenutil/basicfile.cpp') diff --git a/src/zenutil/basicfile.cpp b/src/zenutil/basicfile.cpp index 84e8bed85..99aa6bf39 100644 --- a/src/zenutil/basicfile.cpp +++ b/src/zenutil/basicfile.cpp @@ -452,8 +452,12 @@ TemporaryFile::Close() SetFileInformationByHandle(m_FileHandle, FileDispositionInfo, &Fdi, sizeof Fdi); #else - std::filesystem::path FilePath = zen::PathFromHandle(m_FileHandle); - unlink(FilePath.c_str()); + std::error_code Ec; + std::filesystem::path FilePath = zen::PathFromHandle(m_FileHandle, Ec); + if (!Ec) + { + unlink(FilePath.c_str()); + } #endif BasicFile::Close(); -- cgit v1.2.3