* ext/socket/socket.c (make_hostent): get rid of SEGV on aliases

lookup failure.  (ruby-bugs:PR#1215)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2003-11-07 01:23:27 +00:00
Родитель cac6465677
Коммит a51b5fa52b
2 изменённых файлов: 18 добавлений и 8 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Fri Nov 7 10:23:24 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/socket/socket.c (make_hostent): get rid of SEGV on aliases
lookup failure. (ruby-bugs:PR#1215)
Fri Nov 7 04:08:05 2003 UENO Katsuhiro <katsu@blue.sky.or.jp>
* ext/zlib/zlib.c (Init_zlib): define Zlib::GzipReader#each_line as

Просмотреть файл

@ -1033,8 +1033,6 @@ make_hostent(addr, ipaddr)
ary = rb_ary_new();
rb_ary_push(ary, rb_str_new2(addr->ai_canonname));
names = rb_ary_new();
rb_ary_push(ary, names);
#if defined(HAVE_GETIPNODEBYNAME)
{
int error;
@ -1046,6 +1044,8 @@ make_hostent(addr, ipaddr)
#else
h = gethostbyname(addr->ai_canonname);
#endif
if (h) {
names = rb_ary_new();
if (h->h_aliases != NULL) {
for (pch = h->h_aliases; *pch; pch++) {
rb_ary_push(names, rb_str_new2(*pch));
@ -1054,6 +1054,11 @@ make_hostent(addr, ipaddr)
#if defined(HAVE_GETIPNODEBYNAME)
freehostent(h);
#endif
}
else {
names = rb_ary_new2(0);
}
rb_ary_push(ary, names);
rb_ary_push(ary, INT2NUM(addr->ai_family));
for (ai = addr; ai; ai = ai->ai_next) {
rb_ary_push(ary, (*ipaddr)(ai->ai_addr, ai->ai_addrlen));