Merge pull request #24121 from ashithasantosh/endpoint_memory_leak

Fix memory leak.
pull/24162/head
Ashitha Santhosh 4 years ago committed by GitHub
commit 7862366047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      src/core/lib/iomgr/endpoint_cfstream.cc

@ -365,13 +365,17 @@ grpc_endpoint* grpc_cfstream_endpoint_create(
CFSTREAM_HANDLE_REF(ep_impl->stream_sync, "endpoint create");
ep_impl->peer_string = peer_string;
const int* native_handle =
reinterpret_cast<const int*>(CFReadStreamCopyProperty(
ep_impl->read_stream, kCFStreamPropertySocketNativeHandle));
grpc_resolved_address resolved_local_addr;
resolved_local_addr.len = sizeof(resolved_local_addr.addr);
if (getsockname(*native_handle,
reinterpret_cast<sockaddr*>(resolved_local_addr.addr),
CFDataRef native_handle = static_cast<CFDataRef>(CFReadStreamCopyProperty(
ep_impl->read_stream, kCFStreamPropertySocketNativeHandle));
CFSocketNativeHandle sockfd;
CFDataGetBytes(native_handle, CFRangeMake(0, sizeof(CFSocketNativeHandle)),
(UInt8*)&sockfd);
if (native_handle) {
CFRelease(native_handle);
}
if (getsockname(sockfd, reinterpret_cast<sockaddr*>(resolved_local_addr.addr),
&resolved_local_addr.len) < 0) {
ep_impl->local_address = "";
} else {

Loading…
Cancel
Save