summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index b50747a5e1b..76cb4ae0454 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1061,11 +1061,11 @@ ipaddr(struct sockaddr *sockaddr, int norevlookup)
VALUE ary;
int error;
char hbuf[1024], pbuf[1024];
- char *name;
- name = family_to_str(sockaddr->sa_family);
- if (name)
- family = rb_str_new2(name);
+ family = family_to_str(sockaddr->sa_family);
+ if (!NIL_P(family)) {
+ family = rb_str_dup(family);
+ }
else {
sprintf(pbuf, "unknown:%d", sockaddr->sa_family);
family = rb_str_new2(pbuf);