Fix memory leak I introduced in revision 14343 and fix buffer size calculation to save 4 bytes.

svn path=/trunk/; revision=14349
This commit is contained in:
Filip Navara 2005-03-27 13:03:30 +00:00
parent f39737088b
commit 742ddb108f

View file

@ -56,10 +56,10 @@ GetDllLoadPath(LPCWSTR lpModule)
Length = (lpModuleEnd - lpModule) + 1;
}
Length += GetCurrentDirectoryW(0, NULL) + 1;
Length += GetSystemDirectoryW(NULL, 0) + 1;
Length += GetWindowsDirectoryW(NULL, 0) + 1;
Length += GetEnvironmentVariableW(L"PATH", NULL, 0) + 1;
Length += GetCurrentDirectoryW(0, NULL);
Length += GetSystemDirectoryW(NULL, 0);
Length += GetWindowsDirectoryW(NULL, 0);
Length += GetEnvironmentVariableW(L"PATH", NULL, 0);
EnvironmentBufferW = RtlAllocateHeap(RtlGetProcessHeap(), 0,
Length * sizeof(WCHAR));
@ -181,8 +181,9 @@ LoadLibraryExW (
SearchPath = GetDllLoadPath(
dwFlags & LOAD_WITH_ALTERED_SEARCH_PATH ? lpLibFileName : NULL);
RtlInitUnicodeString (&DllName, (LPWSTR)lpLibFileName);
RtlInitUnicodeString(&DllName, (LPWSTR)lpLibFileName);
Status = LdrLoadDll(SearchPath, dwFlags, &DllName, (PVOID*)&hInst);
RtlFreeHeap(RtlGetProcessHeap(), 0, SearchPath);
if ( !NT_SUCCESS(Status))
{
SetLastErrorByStatus (Status);