Skip to content

Commit

Permalink
Fix FabricTable memoryleak in DeviceControllerSystemState (#14658)
Browse files Browse the repository at this point in the history
FabricTable is instantiated in DeviceControllerFactory::InitSystemState
as shown below

```
    stateParams.fabricTable           = chip::Platform::New<FabricTable>();
```

stateParams (type: DeviceControllerSystemStateParams) is then passed
onto DeviceControllerFactory::mSystemState (type: DeviceControllerSystemState), where stateParams.fabricTable is now stored in mSystemState.mFabrics.

We need to ensure that the original memory allocated in the initial step
is now freed in DeviceControllerSystemState::Shutdown()
  • Loading branch information
kianooshkarami authored Feb 1, 2022
1 parent 0a47fe0 commit a2f9cad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/controller/CHIPDeviceControllerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ CHIP_ERROR DeviceControllerSystemState::Shutdown()
mSessionMgr = nullptr;
}

if (mFabrics != nullptr)
{
chip::Platform::Delete(mFabrics);
mFabrics = nullptr;
}

return CHIP_NO_ERROR;
}

Expand Down

0 comments on commit a2f9cad

Please sign in to comment.