From 21f40234d72c68561e455e652089a1320e82c4be Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 7 Nov 2015 19:47:24 +0000 Subject: [PATCH] [USERENV] - GetProfilesDirectoryA: In case of success, return the length of the profiles directory. - GetProfilesDirectoryW: Set ERROR_INSUFFICIENT_BUFFER, if lpProfilesDir is NULL. svn path=/trunk/; revision=69837 --- reactos/dll/win32/userenv/profile.c | 32 +++++++++++++++++------------ 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/reactos/dll/win32/userenv/profile.c b/reactos/dll/win32/userenv/profile.c index 68d37166de3..b50b6d2a6dd 100644 --- a/reactos/dll/win32/userenv/profile.c +++ b/reactos/dll/win32/userenv/profile.c @@ -687,14 +687,14 @@ GetProfilesDirectoryA(LPSTR lpProfileDir, lpcchSize); if (bResult) { - WideCharToMultiByte(CP_ACP, - 0, - lpBuffer, - -1, - lpProfileDir, - *lpcchSize, - NULL, - NULL); + bResult = WideCharToMultiByte(CP_ACP, + 0, + lpBuffer, + -1, + lpProfileDir, + *lpcchSize, + NULL, + NULL); } GlobalFree(lpBuffer); @@ -713,6 +713,7 @@ GetProfilesDirectoryW(LPWSTR lpProfilesDir, DWORD dwLength; HKEY hKey; LONG Error; + BOOL bRet = FALSE; if (!lpcchSize) { @@ -764,17 +765,22 @@ GetProfilesDirectoryW(LPWSTR lpProfilesDir, { if (*lpcchSize < dwLength) { - *lpcchSize = dwLength; SetLastError(ERROR_INSUFFICIENT_BUFFER); - return FALSE; } - - wcscpy(lpProfilesDir, szProfilesPath); + else + { + wcscpy(lpProfilesDir, szProfilesPath); + bRet = TRUE; + } + } + else + { + SetLastError(ERROR_INSUFFICIENT_BUFFER); } *lpcchSize = dwLength; - return TRUE; + return bRet; }