[KERNEL32] Check the return buffer for NULL before initializing the unicode string...
[reactos.git] / reactos / dll / win32 / kernel32 / client / compname.c
index aadd745..06c11b6 100644 (file)
@@ -20,7 +20,7 @@
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
  * PURPOSE:         Computer name functions
- * FILE:            lib/kernel32/misc/computername.c
+ * FILE:            dll/win32/kernel32/client/compname.c
  * PROGRAMER:       Eric Kohl
  */
 
@@ -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);