From e75c34c2e9f9e1c629cdab13c0c400494f49adb7 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 20 Oct 2003 02:06:42 +0000 Subject: * gc.c (gc_sweep): loosen page free condition to avoid add_heap() race condition. [ruby-dev:21633] * gc.c (gc_sweep): do not update malloc_limit when malloc_increase is smaller than malloc_limit. * ext/socket/socket.c (make_hostent): h_aliases may be NULL. (ruby-bugs PR#1195) * ext/socket/socket.c (sock_s_gethostbyaddr): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/socket/socket.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'ext/socket/socket.c') diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 95ec45bfe6..aa568cf6b3 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -1046,8 +1046,10 @@ make_hostent(addr, ipaddr) #else h = gethostbyname(addr->ai_canonname); #endif - for (pch = h->h_aliases; *pch; pch++) { - rb_ary_push(names, rb_str_new2(*pch)); + if (h->h_aliases != NULL) { + for (pch = h->h_aliases; *pch; pch++) { + rb_ary_push(names, rb_str_new2(*pch)); + } } #if defined(HAVE_GETIPNODEBYNAME) freehostent(h); @@ -2022,8 +2024,10 @@ sock_s_gethostbyaddr(argc, argv) rb_ary_push(ary, rb_str_new2(h->h_name)); names = rb_ary_new(); rb_ary_push(ary, names); - for (pch = h->h_aliases; *pch; pch++) { - rb_ary_push(names, rb_str_new2(*pch)); + if (h->h_aliases != NULL) { + for (pch = h->h_aliases; *pch; pch++) { + rb_ary_push(names, rb_str_new2(*pch)); + } } rb_ary_push(ary, INT2NUM(h->h_addrtype)); #ifdef h_addr -- cgit v1.2.3