Commit 8e67930b authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

kernel32: Reset LastError if GetModuleFileName() succeeds.

parent 8abe262f
......@@ -648,7 +648,10 @@ DWORD WINAPI GetModuleFileNameW( HMODULE hModule, LPWSTR lpFileName, DWORD size
len = min(size, pldr->FullDllName.Length / sizeof(WCHAR));
memcpy(lpFileName, pldr->FullDllName.Buffer, len * sizeof(WCHAR));
if (len < size)
{
lpFileName[len] = '\0';
SetLastError( 0 );
}
else
SetLastError( ERROR_INSUFFICIENT_BUFFER );
}
......
......@@ -44,13 +44,21 @@ static void testGetModuleFileName(const char* name)
/* first test, with enough space in buffer */
memset(bufA, '-', sizeof(bufA));
SetLastError(0xdeadbeef);
len1A = GetModuleFileNameA(hMod, bufA, sizeof(bufA));
ok(GetLastError() == ERROR_SUCCESS ||
broken(GetLastError() == 0xdeadbeef), /* <= XP SP3 */
"LastError was not reset: %u\n", GetLastError());
ok(len1A > 0, "Getting module filename for handle %p\n", hMod);
if (is_unicode_enabled)
{
memset(bufW, '-', sizeof(bufW));
SetLastError(0xdeadbeef);
len1W = GetModuleFileNameW(hMod, bufW, sizeof(bufW) / sizeof(WCHAR));
ok(GetLastError() == ERROR_SUCCESS ||
broken(GetLastError() == 0xdeadbeef), /* <= XP SP3 */
"LastError was not reset: %u\n", GetLastError());
ok(len1W > 0, "Getting module filename for handle %p\n", hMod);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment