diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.c
index b7e5129783..d00b6fcfbe 100644
--- a/src/backend/storage/ipc/latch.c
+++ b/src/backend/storage/ipc/latch.c
@@ -522,7 +522,7 @@ CreateWaitEventSet(MemoryContext context, int nevents)
 	data += MAXALIGN(sizeof(struct pollfd) * nevents);
 #elif defined(WAIT_USE_WIN32)
 	set->handles = (HANDLE) data;
-	data += MAXALIGN(sizeof(HANDLE) * nevents);
+	data += MAXALIGN(sizeof(HANDLE) * (nevents + 1));
 #endif
 
 	set->latch = NULL;
@@ -843,6 +843,12 @@ WaitEventAdjustWin32(WaitEventSet *set, WaitEvent *event)
 				elog(ERROR, "failed to create event for socket: error code %u",
 					 WSAGetLastError());
 		}
+		else
+		{
+			if (!WSAResetEvent(*handle))
+				elog(ERROR, "failed to reset event for socket: error code %u",
+					 WSAGetLastError());
+		}
 		if (WSAEventSelect(event->fd, *handle, flags) != 0)
 			elog(ERROR, "failed to set up event for socket: error code %u",
 				 WSAGetLastError());
