shell32: Avoid infinite loop in _SHExpandEnvironmentStrings.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2018-09-06 12:59:45 +02:00
parent 54530bc493
commit ceea5bda14
1 changed files with 3 additions and 10 deletions

View File

@ -3855,22 +3855,15 @@ static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest)
}
else
{
DWORD ret = ExpandEnvironmentStringsW(szSrc, szDest, MAX_PATH);
DWORD ret = ExpandEnvironmentStringsW(szTemp, szDest, MAX_PATH);
if (ret > MAX_PATH)
hr = E_NOT_SUFFICIENT_BUFFER;
else if (ret == 0)
hr = HRESULT_FROM_WIN32(GetLastError());
else
hr = S_OK;
}
if (SUCCEEDED(hr) && szDest[0] == '%')
strcpyW(szTemp, szDest);
else
{
/* terminate loop */
szTemp[0] = '\0';
else if (!strcmpW( szTemp, szDest )) break; /* nothing expanded */
}
if (SUCCEEDED(hr)) strcpyW(szTemp, szDest);
}
end:
if (key)