Skip to content

Commit c3b6b76

Browse files
Fix crash when a timed invoke happens for a large payload command. (project-chip#38622)
Because we don't pass the exchange through command handling, treating it as out-of-band state instead, we have to maintain that state on all codepaths that can lead to command handling. Also fixes timed writes, but those are not exercised right now. Fixes project-chip#38580
1 parent 4f890cc commit c3b6b76

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/app/InteractionModelEngine.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,9 @@ void InteractionModelEngine::OnTimedInvoke(TimedHandler * apTimedHandler, Messag
19291929
VerifyOrDie(aPayloadHeader.HasMessageType(MsgType::InvokeCommandRequest));
19301930
VerifyOrDie(!apExchangeContext->IsGroupExchangeContext());
19311931

1932+
// Ensure that DataModel::Provider has access to the exchange the message was received on.
1933+
CurrentExchangeValueScope scopedExchangeContext(*this, apExchangeContext);
1934+
19321935
Status status = OnInvokeCommandRequest(apExchangeContext, aPayloadHeader, std::move(aPayload), /* aIsTimedInvoke = */ true);
19331936
if (status != Status::Success)
19341937
{
@@ -1949,6 +1952,9 @@ void InteractionModelEngine::OnTimedWrite(TimedHandler * apTimedHandler, Messagi
19491952
VerifyOrDie(aPayloadHeader.HasMessageType(MsgType::WriteRequest));
19501953
VerifyOrDie(!apExchangeContext->IsGroupExchangeContext());
19511954

1955+
// Ensure that DataModel::Provider has access to the exchange the message was received on.
1956+
CurrentExchangeValueScope scopedExchangeContext(*this, apExchangeContext);
1957+
19521958
Status status = OnWriteRequest(apExchangeContext, aPayloadHeader, std::move(aPayload), /* aIsTimedWrite = */ true);
19531959
if (status != Status::Success)
19541960
{

0 commit comments

Comments
 (0)