Skip to content

Commit

Permalink
Fixed FileExist/DirExist leaking handles when emptydir\* is used.
Browse files Browse the repository at this point in the history
Fixed DirExist leaking handles when only files match.
  • Loading branch information
Lexikos committed Sep 24, 2023
1 parent b444f27 commit db482b9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/util.cpp
Expand Up @@ -1479,12 +1479,18 @@ bool DoesFilePatternExist(LPCTSTR aFilePattern, DWORD *aFileAttr, DWORD aRequire
// Skip . and .., which appear to always be listed first (for dir\* and dir\*.*).
while (wfd.cFileName[0] == '.' && (!wfd.cFileName[1] || wfd.cFileName[1] == '.' && !wfd.cFileName[2]))
if (!FindNextFile(hFile, &wfd))
{
FindClose(hFile);
return false;
}
if (aRequiredAttr) // Caller wants to check for a file/folder with specific attributes.
{
while ((wfd.dwFileAttributes & aRequiredAttr) != aRequiredAttr)
if (!FindNextFile(hFile, &wfd))
{
FindClose(hFile);
return false;
}
// Since above didn't return, a file/folder with the required attribute was found.
}
FindClose(hFile);
Expand Down

0 comments on commit db482b9

Please sign in to comment.