summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/ipsocket.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c
index 7b198bd154..874c0da3e5 100644
--- a/ext/socket/ipsocket.c
+++ b/ext/socket/ipsocket.c
@@ -305,12 +305,13 @@ ip_s_getaddress(VALUE obj, VALUE host)
{
union_sockaddr addr;
struct addrinfo *res = rsock_addrinfo(host, Qnil, SOCK_STREAM, 0);
+ socklen_t len = res->ai_addrlen;
/* just take the first one */
- memcpy(&addr, res->ai_addr, res->ai_addrlen);
+ memcpy(&addr, res->ai_addr, len);
freeaddrinfo(res);
- return rsock_make_ipaddr(&addr.addr, res->ai_addrlen);
+ return rsock_make_ipaddr(&addr.addr, len);
}
void