[secure-transport] add ~SecureTransport() destructor (#11562)

This commit adds a destructor for `SecureTransport` that closes the
socket, and disconnects and removes any tracked sessions.

Removing the sessions ensures that the `SecureSession` instances and
any data allocated within them are properly freed. This handles the
case where the `otInstance` itself is destroyed, ensuring that all
heap-allocated items are cleaned up correctly to prevent memory
leaks.
This commit is contained in:
Abtin Keshavarzian
2025-06-03 22:34:22 -07:00
committed by GitHub
parent 2ae5522bed
commit 7533b1d93a
+1
View File
@@ -721,6 +721,7 @@ public:
protected:
SecureTransport(Instance &aInstance, LinkSecurityMode aLayerTwoSecurity, bool aDatagramTransport);
~SecureTransport(void) { Close(); }
#if OPENTHREAD_CONFIG_TLS_API_ENABLE
void SetExtension(Extension &aExtension) { mExtension = &aExtension; }