mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/ifaddr.c (rsock_getifaddrs): fix possible memory leak.
When a system had no interface, this function used xmalloc for root but did not return any reference to it. This patch fixes it by immediately returning an empty array if no interface is found. Coverity Scan found this bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e7f484d469
commit
a6ae6a8b17
2 changed files with 12 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
|||
Wed Oct 2 21:38:30 2013 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* ext/socket/ifaddr.c (rsock_getifaddrs): fix possible memory leak.
|
||||
When a system had no interface, this function used xmalloc for root
|
||||
but did not return any reference to it. This patch fixes it by
|
||||
immediately returning an empty array if no interface is found.
|
||||
Coverity Scan found this bug.
|
||||
|
||||
Wed Oct 2 21:37:04 2013 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* random.c (make_seed_value): a local array declaration was accessed
|
||||
|
|
|
@ -105,6 +105,10 @@ rsock_getifaddrs(void)
|
|||
if (ret == -1)
|
||||
rb_sys_fail("getifaddrs");
|
||||
|
||||
if (!ifaddrs) {
|
||||
return rb_ary_new();
|
||||
}
|
||||
|
||||
numifaddrs = 0;
|
||||
for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next)
|
||||
numifaddrs++;
|
||||
|
|
Loading…
Add table
Reference in a new issue