From 2c52346a73b96205252ca230798fcdf61e254dc7 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Tue, 15 Mar 2022 10:49:00 +0100 Subject: Handle error GetFinalPathNameByHandleW when file handle is closed --- zencore/filesystem.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 041abaf1d..e2778089b 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -921,6 +921,10 @@ PathFromHandle(void* NativeHandle) } const DWORD RequiredLengthIncludingNul = GetFinalPathNameByHandleW(NativeHandle, nullptr, 0, FILE_NAME_OPENED); + if (RequiredLengthIncludingNul == 0) + { + ThrowLastError(fmt::format("failed to get path from file handle {}", NativeHandle)); + } std::wstring FullPath; FullPath.resize(RequiredLengthIncludingNul - 1); -- cgit v1.2.3