https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3832f83a32040e17c195513f5671ecec2387e6b0

commit 3832f83a32040e17c195513f5671ecec2387e6b0
Author: Pierre Schweitzer <pie...@reactos.org>
AuthorDate: Mon Oct 23 13:39:44 2017 +0200

    [KERNEL32] Check Basep8BitStringToDynamicUnicodeString() return and only 
call -W in case of success
    CID 1419330
---
 dll/win32/kernel32/client/file/npipe.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/dll/win32/kernel32/client/file/npipe.c 
b/dll/win32/kernel32/client/file/npipe.c
index 535f648e59..ee341580c2 100644
--- a/dll/win32/kernel32/client/file/npipe.c
+++ b/dll/win32/kernel32/client/file/npipe.c
@@ -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;

Reply via email to