diff --git a/src/app/clusters/network-commissioning/network-commissioning.h b/src/app/clusters/network-commissioning/network-commissioning.h index 5e3d6d7698ff35..4a28c70d34a323 100644 --- a/src/app/clusters/network-commissioning/network-commissioning.h +++ b/src/app/clusters/network-commissioning/network-commissioning.h @@ -43,7 +43,7 @@ class InstanceListNode : public IntrusiveListNodeBase<> class Instance : public CommandHandlerInterface, public AttributeAccessInterface, #if CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION - private InstanceListNode, + public InstanceListNode, #endif public DeviceLayer::NetworkCommissioning::Internal::BaseDriver::NetworkStatusChangeCallback, public DeviceLayer::NetworkCommissioning::Internal::WirelessDriver::ConnectCallback, @@ -150,7 +150,15 @@ class Instance : public CommandHandlerInterface, Instance(EndpointId aEndpointId, DeviceLayer::NetworkCommissioning::WiFiDriver * apDelegate); Instance(EndpointId aEndpointId, DeviceLayer::NetworkCommissioning::ThreadDriver * apDelegate); Instance(EndpointId aEndpointId, DeviceLayer::NetworkCommissioning::EthernetDriver * apDelegate); - virtual ~Instance() = default; + virtual ~Instance() + { +#if CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION + if (sInstances.Contains(this)) + { + sInstances.Remove(this); + } +#endif + }; }; // namespace NetworkCommissioning // NetworkDriver for the devices that don't have / don't need a real network driver.