summaryrefslogtreecommitdiff
path: root/ext/socket
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-07 12:14:29 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-07 12:14:29 +0000
commit1aa54bebaf274bc08e72f9ad3854c7ad592c344a (patch)
tree0acefbf45581adb73363d4619ba5fbe6eb113a18 /ext/socket
parentfc3b4d06ca4f5c46457983b51f844f5afcd325df (diff)
* ext/socket/socket.c (sock_s_getnameinfo): Save errno for EAI_SYSTEM.
Reported by Saravana kumar. [ruby-core:61820] [Bug #9697] Fixed by Heesob Park. [ruby-core:61868] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket')
-rw-r--r--ext/socket/socket.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 67bfcb3..6b145ac 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1346,7 +1346,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
int fl;
struct rb_addrinfo *res = NULL;
struct addrinfo hints, *r;
- int error;
+ int error, saved_errno;
union_sockaddr ss;
struct sockaddr *sap;
socklen_t salen;
@@ -1460,11 +1460,15 @@ sock_s_getnameinfo(int argc, VALUE *argv)
return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf));
error_exit_addr:
+ saved_errno = errno;
if (res) rb_freeaddrinfo(res);
+ errno = saved_errno;
rsock_raise_socket_error("getaddrinfo", error);
error_exit_name:
+ saved_errno = errno;
if (res) rb_freeaddrinfo(res);
+ errno = saved_errno;
rsock_raise_socket_error("getnameinfo", error);
UNREACHABLE;