Skip to content

Commit

Permalink
Fix leaked readClient in onFabricRemoved call
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google committed Jan 24, 2025
1 parent 74593dc commit e332076
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1967,12 +1967,14 @@ void InteractionModelEngine::OnFabricRemoved(const FabricTable & fabricTable, Fa
});

#if CHIP_CONFIG_ENABLE_READ_CLIENT
for (auto * readClient = mpActiveReadClientList; readClient != nullptr; readClient = readClient->GetNextClient())
for (auto * readClient = mpActiveReadClientList; readClient != nullptr;)
{
if (readClient->GetFabricIndex() == fabricIndex)
{
ChipLogProgress(InteractionModel, "Fabric removed, deleting obsolete read client with FabricIndex: %u", fabricIndex);
auto * nextReadClient = readClient->GetNextClient();
readClient->Close(CHIP_ERROR_IM_FABRIC_DELETED, false);
readClient = nextReadClient;
}
}
#endif // CHIP_CONFIG_ENABLE_READ_CLIENT
Expand Down

0 comments on commit e332076

Please sign in to comment.