mirror of
https://github.com/reactos/reactos.git
synced 2024-09-26 04:28:40 +00:00
[SHLWAPI] Fix a trivial bug in PathFileExistsDefExtW() that seems to exist since 16+ years in Wine.
Suppose dwFlags == 1 | 4 (i.e. skipping the flag 2). Then the while-loop would only run once, because at the second iteration (after dwWhich >>= 1; has been executed once), dwWhich value == 2, but dwWhich & 0x1 == 0, which makes the while-loop condition false. Instead the loop should run, but the handling of the extension should be skipped.
This commit is contained in:
parent
8ec3580123
commit
3199fdbd44
|
@ -40,7 +40,12 @@
|
|||
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
||||
|
||||
#ifdef __REACTOS__
|
||||
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi_undoc.h>
|
||||
|
||||
int WINAPI IsNetDrive(int drive);
|
||||
|
||||
#else
|
||||
|
||||
/* Get a function pointer from a DLL handle */
|
||||
|
@ -1127,17 +1132,32 @@ BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath,DWORD dwWhich)
|
|||
if (dwWhich)
|
||||
{
|
||||
LPCWSTR szExt = PathFindExtensionW(lpszPath);
|
||||
#ifndef __REACTOS__
|
||||
if (!*szExt || dwWhich & 0x40)
|
||||
#else
|
||||
if (!*szExt || dwWhich & WHICH_OPTIONAL)
|
||||
#endif
|
||||
{
|
||||
size_t iChoose = 0;
|
||||
int iLen = lstrlenW(lpszPath);
|
||||
if (iLen > (MAX_PATH - 5))
|
||||
return FALSE;
|
||||
#ifndef __REACTOS__
|
||||
while ( (dwWhich & 0x1) && pszExts[iChoose][0] )
|
||||
#else
|
||||
while (pszExts[iChoose][0])
|
||||
#endif
|
||||
{
|
||||
#ifdef __REACTOS__
|
||||
if (dwWhich & 0x1)
|
||||
{
|
||||
#endif
|
||||
lstrcpyW(lpszPath + iLen, pszExts[iChoose]);
|
||||
if (PathFileExistsW(lpszPath))
|
||||
return TRUE;
|
||||
#ifdef __REACTOS__
|
||||
}
|
||||
#endif
|
||||
iChoose++;
|
||||
dwWhich >>= 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue