From 2423b35126641971523e63c6ac6888b297e19f5a Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 28 Jun 2015 15:41:18 +0000 Subject: [PATCH] [CMLIB] HvFree: - Free the BaseBlock. - Do not free the hive itself because the HHIVE is part of the CMHIVE structure and freeing it here could be an unpleasant surprise. [NTOSKRNL] CmpDestroyHive: Free the CMHIVE after calling HvFree. CmUnloadKey: Free the hive storage, the hive locks and the CMHIVE properly. svn path=/trunk/; revision=68303 --- reactos/lib/cmlib/hiveinit.c | 10 ++++++++-- reactos/ntoskrnl/config/cmapi.c | 15 ++++++++++++++- reactos/ntoskrnl/config/cminit.c | 5 ++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/reactos/lib/cmlib/hiveinit.c b/reactos/lib/cmlib/hiveinit.c index 7aed3d6fda2..9463d6d2725 100644 --- a/reactos/lib/cmlib/hiveinit.c +++ b/reactos/lib/cmlib/hiveinit.c @@ -529,6 +529,7 @@ HvInitialize( * @name HvFree * * Free all stroage and handles associated with hive descriptor. + * But do not free the hive descriptor itself. */ VOID CMAPI @@ -544,9 +545,14 @@ HvFree( } HvpFreeHiveBins(RegistryHive); - } - RegistryHive->Free(RegistryHive, 0); + /* Free the BaseBlock */ + if (RegistryHive->BaseBlock) + { + RegistryHive->Free(RegistryHive->BaseBlock, 0); + RegistryHive->BaseBlock = NULL; + } + } } /* EOF */ diff --git a/reactos/ntoskrnl/config/cmapi.c b/reactos/ntoskrnl/config/cmapi.c index e862b1da525..869a6768ec6 100644 --- a/reactos/ntoskrnl/config/cmapi.c +++ b/reactos/ntoskrnl/config/cmapi.c @@ -2241,7 +2241,20 @@ CmUnloadKey(IN PCM_KEY_CONTROL_BLOCK Kcb, /* Remove the hive from the hive file list */ CmpRemoveFromHiveFileList(CmHive); - /* FIXME: Destroy the hive */ + /* FIXME: More cleanup */ + + /* Free the hive storage */ + HvFree(Hive); + + /* Delete the flusher lock */ + ExDeleteResourceLite(CmHive->FlusherLock); + ExFreePoolWithTag(CmHive->FlusherLock, TAG_CM); + + /* Delete the view lock */ + ExFreePoolWithTag(CmHive->ViewLock, TAG_CM); + + /* Free the hive */ + CmpFree(CmHive, TAG_CM); return STATUS_SUCCESS; } diff --git a/reactos/ntoskrnl/config/cminit.c b/reactos/ntoskrnl/config/cminit.c index bf23d20750a..7b542c1b338 100644 --- a/reactos/ntoskrnl/config/cminit.c +++ b/reactos/ntoskrnl/config/cminit.c @@ -257,9 +257,12 @@ CmpDestroyHive(IN PCMHIVE CmHive) /* Delete the view lock */ ExFreePoolWithTag(CmHive->ViewLock, TAG_CM); - /* Free the hive */ + /* Free the hive storage */ HvFree(&CmHive->Hive); + /* Free the hive */ + CmpFree(CmHive, TAG_CM); + return STATUS_SUCCESS; } -- 2.17.1