https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2ed4b3f78098975ecebce…
commit 2ed4b3f78098975ecebce9e7bbb764c5e1b3aaa0
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun Oct 20 10:04:08 2019 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun Oct 20 15:01:55 2019 +0200
[NETCFGX] Free all component data on INetCfg_fnUninitialize()
---
dll/win32/netcfgx/netcfg_iface.c | 49 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
diff --git a/dll/win32/netcfgx/netcfg_iface.c b/dll/win32/netcfgx/netcfg_iface.c
index fe4e69d11e0..e8553abeee7 100644
--- a/dll/win32/netcfgx/netcfg_iface.c
+++ b/dll/win32/netcfgx/netcfg_iface.c
@@ -688,17 +688,64 @@ ApplyOrCancelChanges(
}
}
+VOID
+FreeComponentItem(NetCfgComponentItem *pItem)
+{
+ CoTaskMemFree(pItem->szDisplayName);
+ CoTaskMemFree(pItem->szHelpText);
+ CoTaskMemFree(pItem->szId);
+ CoTaskMemFree(pItem->szBindName);
+ CoTaskMemFree(pItem->szNodeId);
+ CoTaskMemFree(pItem->pszBinding);
+ CoTaskMemFree(pItem);
+}
+
HRESULT
WINAPI
INetCfg_fnUninitialize(
INetCfg * iface)
{
INetCfgImpl *This = (INetCfgImpl *)iface;
+ NetCfgComponentItem *pItem;
if (!This->bInitialized)
return NETCFG_E_NOT_INITIALIZED;
- return E_FAIL;
+ /* Free the services */
+ while (This->pService != NULL)
+ {
+ pItem = This->pService;
+ This->pService = pItem->pNext;
+ FreeComponentItem(pItem);
+ }
+
+ /* Free the clients */
+ while (This->pClient != NULL)
+ {
+ pItem = This->pClient;
+ This->pClient = pItem->pNext;
+ FreeComponentItem(pItem);
+ }
+
+ /* Free the protocols */
+ while (This->pProtocol != NULL)
+ {
+ pItem = This->pProtocol;
+ This->pProtocol = pItem->pNext;
+ FreeComponentItem(pItem);
+ }
+
+ /* Free the adapters */
+ while (This->pNet != NULL)
+ {
+ pItem = This->pNet;
+ This->pNet = pItem->pNext;
+ FreeComponentItem(pItem);
+ }
+
+ This->bInitialized = FALSE;
+
+ return S_OK;
}