[KERNEL32] Check the return buffer for NULL before initializing the unicode string...
[reactos.git] / reactos / dll / win32 / kernel32 / client / compname.c
index 407850a..06c11b6 100644 (file)
@@ -263,8 +263,15 @@ GetComputerNameExA(COMPUTER_NAME_FORMAT NameType,
     UNICODE_STRING UnicodeString;
     ANSI_STRING AnsiString;
     BOOL Result;
-    PWCHAR TempBuffer = RtlAllocateHeap( RtlGetProcessHeap(), 0, *nSize * sizeof(WCHAR) );
+    PWCHAR TempBuffer;
 
+    if (!lpBuffer)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    TempBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, *nSize * sizeof(WCHAR));
     if (!TempBuffer)
     {
         SetLastError(ERROR_NOT_ENOUGH_MEMORY);