From ff5f4d8cccb44e2743062601f4806dae04193d9f Mon Sep 17 00:00:00 2001 From: hai007 Date: Thu, 6 Oct 2022 15:41:55 -0700 Subject: [PATCH] Use strongified advertiser inside block Fixes unused-variable warning and a possible memory leak PiperOrigin-RevId: 479430565 --- connections/clients/ios/Internal/GNCAdvertiser.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/connections/clients/ios/Internal/GNCAdvertiser.mm b/connections/clients/ios/Internal/GNCAdvertiser.mm index 34b20b06..0a16401d 100644 --- a/connections/clients/ios/Internal/GNCAdvertiser.mm +++ b/connections/clients/ios/Internal/GNCAdvertiser.mm @@ -150,7 +150,7 @@ class GNCAdvertiserConnectionListener { // The connection was accepted by the client. if (payload_listener_ == nullptr) { payload_listener_ = std::make_unique( - advertiser.core, + strongAdvertiser.core, ^{ return endpointInfo.connectionHandlers; }, @@ -158,7 +158,7 @@ class GNCAdvertiserConnectionListener { return endpointInfo.connection.payloads; }); } - advertiser.core->_core->AcceptConnection( + strongAdvertiser.core->_core->AcceptConnection( CppStringFromObjCString(endpointId), PayloadListener{ .payload_cb = absl::bind_front(&GNCPayloadListener::OnPayload, @@ -169,7 +169,7 @@ class GNCAdvertiserConnectionListener { ResultListener{}); } else { // The connection was rejected by the client. - advertiser.core->_core->RejectConnection(CppStringFromObjCString(endpointId), + strongAdvertiser.core->_core->RejectConnection(CppStringFromObjCString(endpointId), ResultListener{}); } });