Skip to content

Commit 9d7e25a

Browse files
committed
common/wincompat.c: fix pipe_ready() to measure strlen(data) once [#3302]
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent bff98f2 commit 9d7e25a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

common/wincompat.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ int pipe_ready(pipe_conn_t *conn)
643643
{
644644
DWORD bytesRead;
645645
BOOL res;
646+
size_t len;
646647

647648
res = GetOverlappedResult(conn->handle, &conn->overlapped, &bytesRead, FALSE);
648649
if (res == 0) {
@@ -677,9 +678,10 @@ int send_to_named_pipe(const char * pipe_name, const char * data)
677678
return 1;
678679
}
679680

680-
result = WriteFile(pipe, data, strlen(data) + 1, &bytesWritten, NULL);
681+
len = strlen(data);
682+
result = WriteFile(pipe, data, len + 1, &bytesWritten, NULL);
681683

682-
if (result == 0 || bytesWritten != strlen(data) + 1) {
684+
if (result == 0 || bytesWritten != len + 1) {
683685
CloseHandle(pipe);
684686
return 1;
685687
}

0 commit comments

Comments
 (0)