Skip to content

Commit

Permalink
Fix BufferSize in g_read for Windows (#1722)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreivinca authored Apr 15, 2024
1 parent 727c179 commit 0795a5d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ static int g_read(lua_State* L, int stream, unsigned long read_size) {
return luaL_error(L, "error: redirect to handles, FILE* and paths are not supported");
#if _WIN32
int writable_stream_idx = stream - 1;
if (self->reading[writable_stream_idx] || !ReadFile(self->child_pipes[stream][0], self->buffer[writable_stream_idx], READ_BUF_SIZE, NULL, &self->overlapped[writable_stream_idx])) {
if (self->reading[writable_stream_idx] || !ReadFile(self->child_pipes[stream][0], self->buffer[writable_stream_idx], read_size > READ_BUF_SIZE ? READ_BUF_SIZE : read_size, NULL, &self->overlapped[writable_stream_idx])) {
if (self->reading[writable_stream_idx] || GetLastError() == ERROR_IO_PENDING) {
self->reading[writable_stream_idx] = true;
DWORD bytesTransferred = 0;
Expand Down

0 comments on commit 0795a5d

Please sign in to comment.