diff --git a/reactos/dll/win32/kernel32/misc/ldr.c b/reactos/dll/win32/kernel32/misc/ldr.c index 9fba9583e52..a967fc6ffa6 100644 --- a/reactos/dll/win32/kernel32/misc/ldr.c +++ b/reactos/dll/win32/kernel32/misc/ldr.c @@ -266,14 +266,7 @@ LoadLibraryExW ( * 'native' libraries only */ Status = LoadLibraryAsDatafile(SearchPath, DllName.Buffer, &hInst); - RtlFreeUnicodeString(&DllName); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return NULL; - } - - return hInst; + goto done; } } @@ -292,6 +285,7 @@ LoadLibraryExW ( Status = LdrLoadDll(SearchPath, &dwFlags, &DllName, (PVOID*)&hInst); } +done: RtlFreeHeap(RtlGetProcessHeap(), 0, SearchPath); if (FreeString) RtlFreeUnicodeString(&DllName);