From 55bcda10eec55c35717d4d1f759ed29d8a1cff77 Mon Sep 17 00:00:00 2001 From: Tyrie Vella Date: Tue, 19 May 2026 13:35:19 -0700 Subject: [PATCH] Fix handle leak in GetFinalPathName The fileHandle obtained from CreateFileW was never closed after calling GetFinalPathNameByHandleW, leaking a kernel handle on every invocation. Add CloseHandle(fileHandle) on both the success path and the error path before die(). Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella --- GVFS/GVFS.NativeHooks.Common/common.windows.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/GVFS/GVFS.NativeHooks.Common/common.windows.cpp b/GVFS/GVFS.NativeHooks.Common/common.windows.cpp index 35c7db8d4..88e85f9d4 100644 --- a/GVFS/GVFS.NativeHooks.Common/common.windows.cpp +++ b/GVFS/GVFS.NativeHooks.Common/common.windows.cpp @@ -28,6 +28,7 @@ PATH_STRING GetFinalPathName(const PATH_STRING& path) wchar_t finalPathByHandle[MAX_PATH] = { 0 }; DWORD finalPathSize = GetFinalPathNameByHandleW(fileHandle, finalPathByHandle, MAX_PATH, FILE_NAME_NORMALIZED); + CloseHandle(fileHandle); if (finalPathSize == 0) { die(ReturnCode::PathNameError, "Could not get final path name by handle for %ls, Error: %d\n", path.c_str(), GetLastError());