From e58af99cc1425e4589fa6f322b299b385e2fdea6 Mon Sep 17 00:00:00 2001 From: Dmitry Chapyshev Date: Sat, 11 Jul 2009 14:18:06 +0000 Subject: [PATCH] - Fix 3 "kernel32_winetest environ" tests. All environ tests passed now svn path=/trunk/; revision=41887 --- reactos/dll/win32/kernel32/misc/computername.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/kernel32/misc/computername.c b/reactos/dll/win32/kernel32/misc/computername.c index e5bf86c648d..b07e644ab09 100644 --- a/reactos/dll/win32/kernel32/misc/computername.c +++ b/reactos/dll/win32/kernel32/misc/computername.c @@ -92,11 +92,19 @@ GetComputerNameFromRegistry(LPWSTR RegistryKey, return FALSE; } - if (*nSize > (KeyInfo->DataLength / sizeof(WCHAR))) + if (lpBuffer && *nSize > (KeyInfo->DataLength / sizeof(WCHAR))) { *nSize = KeyInfo->DataLength / sizeof(WCHAR) - 1; lpBuffer[*nSize] = 0; } + else + { + RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo); + ZwClose(KeyHandle); + *nSize = ReturnSize; + SetLastErrorByStatus(STATUS_BUFFER_OVERFLOW); + return FALSE; + } RtlCopyMemory(lpBuffer, KeyInfo->Data, *nSize * sizeof(WCHAR)); @@ -254,7 +262,8 @@ GetComputerNameExA(COMPUTER_NAME_FORMAT NameType, if (!TempBuffer) { - return ERROR_OUTOFMEMORY; + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; } AnsiString.MaximumLength = (USHORT)*nSize;