summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYO4 <[email protected]>2025-01-22 18:30:08 +0900
committerNobuyoshi Nakada <[email protected]>2025-03-19 01:28:59 +0900
commit9c71b5901c700bb2b18b0083130e65e97e386089 (patch)
treecb797d2bb58a791c102931d7385162fad3eb0c79
parentc717dbdc8198ddaedb6f7562cb74038fa2b30c6f (diff)
fix rb_w32_strerror when errno < 0
change SystemCallError.new(-1) message on Windows (Bug #21083) https://bugs.ruby-lang.org/issues/21083
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12622
-rw-r--r--win32/win32.c8
1 files 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)