Skip to content

Commit 55bcda1

Browse files
committed
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 <tyrielv@gmail.com>
1 parent 1e748bb commit 55bcda1

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

GVFS/GVFS.NativeHooks.Common/common.windows.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ PATH_STRING GetFinalPathName(const PATH_STRING& path)
2828

2929
wchar_t finalPathByHandle[MAX_PATH] = { 0 };
3030
DWORD finalPathSize = GetFinalPathNameByHandleW(fileHandle, finalPathByHandle, MAX_PATH, FILE_NAME_NORMALIZED);
31+
CloseHandle(fileHandle);
3132
if (finalPathSize == 0)
3233
{
3334
die(ReturnCode::PathNameError, "Could not get final path name by handle for %ls, Error: %d\n", path.c_str(), GetLastError());

0 commit comments

Comments
 (0)