From ad7bf806116fd98dad4bfd2fabfe4f918fe3f4db Mon Sep 17 00:00:00 2001 From: Ico Doornekamp Date: Tue, 30 May 2023 19:33:34 +0200 Subject: [PATCH] fix for crash on windows in src/core/ev.c: initialze state->fromlen before doing WSARecvFrom() to prevent crash (likely caused by the memcpy() of `state->from` at line 2301 with the memcpy length set to -1) --- src/core/ev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/ev.c b/src/core/ev.c index a7056b9c..f9e830b6 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -2320,6 +2320,7 @@ JanetAsyncStatus ev_machine_read(JanetListenerState *s, JanetAsyncEvent event) { if (state->mode == JANET_ASYNC_READMODE_RECVFROM) { state->wbuf.len = (ULONG) chunk_size; state->wbuf.buf = (char *) state->chunk_buf; + state->fromlen = sizeof(state->from); status = WSARecvFrom((SOCKET) s->stream->handle, &state->wbuf, 1, NULL, &state->flags, &state->from, &state->fromlen, &state->overlapped, NULL); if (status && (WSA_IO_PENDING != WSAGetLastError())) {