Skip to content

Commit 1267139

Browse files
bzbarsky-applepull[bot]
authored andcommitted
Fix reference to out-of-scope temporary in SetUpCodePairer. (#24316)
The old code used to get a reference to a member of a temporary, but nothing kept the temporary alive (it was not assigned to a named reference or anything), so it went out of scope and got destroyed. And then we were referencing garbage. Explicitly keep references to all the things we are using, so they don't go away on us.
1 parent ec39efa commit 1267139

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/controller/SetUpCodePairer.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ void SetUpCodePairer::OnPairingComplete(CHIP_ERROR error)
491491
if (CHIP_ERROR_TIMEOUT == error && mCurrentPASEParameters.HasValue())
492492
{
493493
const auto & params = mCurrentPASEParameters.Value();
494-
auto & ip = params.GetPeerAddress().GetIPAddress();
494+
const auto & peer = params.GetPeerAddress();
495+
const auto & ip = peer.GetIPAddress();
495496
auto err = Dnssd::Resolver::Instance().ReconfirmRecord(params.mHostName, ip, params.mInterfaceId);
496497
if (CHIP_NO_ERROR != err && CHIP_ERROR_NOT_IMPLEMENTED != err)
497498
{

0 commit comments

Comments
 (0)