[KERNEL32] Check Basep8BitStringToDynamicUnicodeString() return and only call -W...
[reactos.git] / dll / win32 / kernel32 / client / file / npipe.c
index 6698acd..ee34158 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS Win32 Kernel Library
- * FILE:            lib/kernel32/file/npipe.c
+ * FILE:            dll/win32/kernel32/client/file/npipe.c
  * PURPOSE:         Named Pipe Functions
  * PROGRAMMER:      Alex Ionescu (alex@relsoft.net)
  *                  Ariadne ( ariadne@xs4all.nl)
@@ -344,17 +344,18 @@ WINAPI
 WaitNamedPipeA(LPCSTR lpNamedPipeName,
                DWORD nTimeOut)
 {
-    BOOL r;
+    BOOL r = FALSE;
     UNICODE_STRING NameU;
 
     /* Convert the name to Unicode */
-    Basep8BitStringToDynamicUnicodeString(&NameU, lpNamedPipeName);
-
-    /* Call the Unicode API */
-    r = WaitNamedPipeW(NameU.Buffer, nTimeOut);
+    if (Basep8BitStringToDynamicUnicodeString(&NameU, lpNamedPipeName))
+    {
+        /* Call the Unicode API */
+        r = WaitNamedPipeW(NameU.Buffer, nTimeOut);
 
-    /* Free the Unicode string */
-    RtlFreeUnicodeString(&NameU);
+        /* Free the Unicode string */
+        RtlFreeUnicodeString(&NameU);
+    }
 
     /* Return result */
     return r;
@@ -944,7 +945,7 @@ GetNamedPipeHandleStateW(HANDLE hNamedPipe,
     if (lpUserName != NULL)
     {
       /* FIXME - open the thread token, call ImpersonateNamedPipeClient() and
-                 retreive the user name with GetUserName(), revert the impersonation
+                 retrieve the user name with GetUserName(), revert the impersonation
                  and finally restore the thread token */
     }