From 8601f5a42eecadcc39b483a072b18b29a3a4e23c Mon Sep 17 00:00:00 2001 From: Misaki Shioi Date: Wed, 18 Mar 2026 12:37:14 +0900 Subject: [PATCH] Fix reading freed memory in rb_getaddrinfo --- ext/socket/raddrinfo.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index 6cdf5c6abc..f1fbcc35de 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -601,13 +601,9 @@ start: if (need_free) free_getaddrinfo_arg(arg); if (timedout) { - if (arg->ai) { - rsock_raise_user_specified_timeout(arg->ai, Qnil, Qnil); - } else { - VALUE host = rb_str_new_cstr(hostp); - VALUE port = rb_str_new_cstr(portp); - rsock_raise_user_specified_timeout(NULL, host, port); - } + VALUE host = rb_str_new_cstr(hostp); + VALUE port = rb_str_new_cstr(portp); + rsock_raise_user_specified_timeout(NULL, host, port); } // If the current thread is interrupted by asynchronous exception, the following raises the exception.