1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

raddrinfo.c: fix memory leak

* ext/socket/raddrinfo.c (addrinfo_mload): fix memory leak of
  addrinfo.  [ruby-dev:48923] [Bug #11051]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-04-08 23:24:10 +00:00
parent 119960dc56
commit 816504c29c
3 changed files with 17 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Thu Apr 9 08:24:03 2015 Masahiro Tomita <tommy@tmtm.org>
* ext/socket/raddrinfo.c (addrinfo_mload): fix memory leak of
addrinfo. [ruby-dev:48923] [Bug #11051]
Wed Apr 8 17:45:02 2015 Shannon Skipper <shannonskipper@gmail.com>
* version.c (Init_version): the version of the engine or

View file

@ -1643,6 +1643,7 @@ addrinfo_mload(VALUE self, VALUE ary)
len = res->ai->ai_addrlen;
memcpy(&ss, res->ai->ai_addr, res->ai->ai_addrlen);
rb_freeaddrinfo(res);
break;
}
}

View file

@ -468,6 +468,17 @@ class TestSocketAddrinfo < Test::Unit::TestCase
assert_equal(ai1.canonname, ai2.canonname)
end
def test_marshal_memory_leak
bug11051 = '[ruby-dev:48923] [Bug #11051]'
assert_no_memory_leak(%w[-rsocket], <<-prep, <<-code, bug11051, rss: true, limit: 1.1)
d = Marshal.dump(Addrinfo.tcp("127.0.0.1", 80))
1000.times {Marshal.load(d)}
prep
GC.start
20_000.times {Marshal.load(d)}
code
end
if Socket.const_defined?("AF_INET6") && Socket::AF_INET6.is_a?(Integer)
def test_addrinfo_new_inet6