[KERNEL32] Check Basep8BitStringToDynamicUnicodeString() return and only call -W...
authorPierre Schweitzer <pierre@reactos.org>
Mon, 23 Oct 2017 11:39:44 +0000 (13:39 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Mon, 23 Oct 2017 11:39:44 +0000 (13:39 +0200)
CID 1419330

dll/win32/kernel32/client/file/npipe.c

index 535f648..ee34158 100644 (file)
@@ -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;