From 37bd5ad800e814adf84cf0b5c949b6c79b45c3db Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 10 Aug 2016 12:12:56 +0200 Subject: [PATCH] Fix race condition in CreatePipeOverlapped fixes #10075 --- lib/base/process.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/base/process.cpp b/lib/base/process.cpp index 831bf36ae..76628cce2 100644 --- a/lib/base/process.cpp +++ b/lib/base/process.cpp @@ -329,13 +329,16 @@ static BOOL CreatePipeOverlapped(HANDLE *outReadPipe, HANDLE *outWritePipe, if (size == 0) size = 8192; + int currentIndex; + { boost::mutex::scoped_lock lock(mutex); + currentIndex = pipeIndex; pipeIndex++; } char pipeName[128]; - sprintf(pipeName, "\\\\.\\Pipe\\OverlappedPipe.%d.%d", (int)GetCurrentProcessId(), pipeIndex); + sprintf(pipeName, "\\\\.\\Pipe\\OverlappedPipe.%d.%d", (int)GetCurrentProcessId(), currentIndex); *outReadPipe = CreateNamedPipe(pipeName, PIPE_ACCESS_INBOUND | readMode, PIPE_TYPE_BYTE | PIPE_WAIT, 1, size, size, 60 * 1000, securityAttributes);