Skip to content

Commit

Permalink
Merge pull request #5722 from colinsurprenant/resolv_leak
Browse files Browse the repository at this point in the history
use same parameter for DNS.allocate_request_id/free_request_id to fix leak
  • Loading branch information
headius committed Oct 28, 2019
2 parents 21a6642 + c62fa4a commit 439aceb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ruby/stdlib/resolv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ def sender(msg, data, host, port=Port)
sock = @socks_hash[host.index(':') ? "::" : "0.0.0.0"]
return nil if !sock
service = [IPAddr.new(host), port]
id = DNS.allocate_request_id(host, port)
id = DNS.allocate_request_id(service[0].to_s, port)
request = msg.encode
request[0,2] = [id].pack('n')
return @senders[[service, id]] =
Expand All @@ -795,7 +795,7 @@ def close
if @initialized
super
@senders.each_key {|service, id|
DNS.free_request_id(service[0], service[1], id)
DNS.free_request_id(service[0].to_s, service[1], id)
}
@initialized = false
end
Expand Down

0 comments on commit 439aceb

Please sign in to comment.