Skip to content

Commit d4bb284

Browse files
committed
Minor fix to TestExchangeHolder
1 parent 66f534c commit d4bb284

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/messaging/tests/TestExchangeHolder.cpp

+15-3
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ CHIP_ERROR MockProtocolResponder::OnMessageReceived(ExchangeContext * ec, const
206206
{
207207
err = mExchangeCtx->SendMessage(chip::Protocols::MockProtocol::MessageType::kMsg2, std::move(respBuffer),
208208
SendMessageFlags::kExpectResponse);
209-
mExchangeCtx->ClearInjectedFailures();
209+
if (mExchangeCtx)
210+
{
211+
mExchangeCtx->ClearInjectedFailures();
212+
}
213+
210214
ReturnErrorOnFailure(err);
211215
}
212216

@@ -267,7 +271,11 @@ CHIP_ERROR MockProtocolInitiator::StartInteraction(SessionHandle & sessionHandle
267271
{
268272
auto err = mExchangeCtx->SendMessage(chip::Protocols::MockProtocol::MessageType::kMsg1, std::move(buffer),
269273
SendMessageFlags::kExpectResponse);
270-
mExchangeCtx->ClearInjectedFailures();
274+
if (mExchangeCtx)
275+
{
276+
mExchangeCtx->ClearInjectedFailures();
277+
}
278+
271279
ReturnErrorOnFailure(err);
272280
}
273281

@@ -307,7 +315,11 @@ CHIP_ERROR MockProtocolInitiator::OnMessageReceived(ExchangeContext * ec, const
307315
{
308316
err = mExchangeCtx->SendMessage(chip::Protocols::MockProtocol::MessageType::kMsg3, std::move(respBuffer),
309317
SendMessageFlags::kNone);
310-
mExchangeCtx->ClearInjectedFailures();
318+
if (mExchangeCtx)
319+
{
320+
mExchangeCtx->ClearInjectedFailures();
321+
}
322+
311323
ReturnErrorOnFailure(err);
312324
}
313325

0 commit comments

Comments
 (0)