From 9c71b5901c700bb2b18b0083130e65e97e386089 Mon Sep 17 00:00:00 2001 From: YO4 Date: Wed, 22 Jan 2025 18:30:08 +0900 Subject: [PATCH] fix rb_w32_strerror when errno < 0 change SystemCallError.new(-1) message on Windows (Bug #21083) https://bugs.ruby-lang.org/issues/21083 --- win32/win32.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/win32/win32.c b/win32/win32.c index 784c150393..a2daba2fa1 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2805,11 +2805,11 @@ rb_w32_strerror(int e) DWORD source = 0; char *p; - if (e < 0 || e > sys_nerr) { - if (e < 0) - e = GetLastError(); + if (e < 0) + strlcpy(buffer, "Unknown Error", sizeof(buffer)); + else if (e > sys_nerr) { #if WSAEWOULDBLOCK != EWOULDBLOCK - else if (e >= EADDRINUSE && e <= EWOULDBLOCK) { + if (e >= EADDRINUSE && e <= EWOULDBLOCK) { static int s = -1; int i; if (s < 0)