[KERNEL32] WaitNamedPipeW: Free Unicode buffer when leaving the function
[reactos.git] / reactos / dll / win32 / kernel32 / file / npipe.c
index ec68156..55aeed9 100644 (file)
@@ -496,6 +496,7 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
     if (!NT_SUCCESS(Status))
     {
         SetLastErrorByStatus(Status);
+        RtlFreeUnicodeString(&NamedPipeName);
         return FALSE;
     }
 
@@ -538,9 +539,11 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
     if (!NT_SUCCESS(Status))
     {
         SetLastErrorByStatus(Status);
+        RtlFreeUnicodeString(&NamedPipeName);
         return FALSE;
     }
 
+    RtlFreeUnicodeString(&NamedPipeName);
     return TRUE;
 }
 #endif
@@ -1069,7 +1072,7 @@ PeekNamedPipe(HANDLE hNamedPipe,
     NTSTATUS Status;
 
     /* Calculate the buffer space that we'll need and allocate it */
-    BufferSize = nBufferSize + FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]);
+    BufferSize = nBufferSize + sizeof(FILE_PIPE_PEEK_BUFFER);
     Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferSize);
     if (Buffer == NULL)
     {