From c8d9e123b7fcc646a359ca9c3de7d58f03eee5ed Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 22 Dec 2008 13:35:08 +0000 Subject: [PATCH] - Fix KCB ref leaks in Cm parse routine (thanks Stefan). svn path=/trunk/; revision=38269 --- reactos/ntoskrnl/config/cmparse.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/reactos/ntoskrnl/config/cmparse.c b/reactos/ntoskrnl/config/cmparse.c index 7e6d9d264c8..2757fbb8cce 100644 --- a/reactos/ntoskrnl/config/cmparse.c +++ b/reactos/ntoskrnl/config/cmparse.c @@ -977,7 +977,13 @@ CmpBuildHashStackAndLookupCache(IN PCM_KEY_BODY ParseObject, /* Return hive and cell data */ *Hive = (*Kcb)->KeyHive; *Cell = (*Kcb)->KeyCell; - + + /* Make sure it's not a dead KCB */ + ASSERT((*Kcb)->RefCount > 0); + + /* Reference it */ + (VOID)CmpReferenceKeyControlBlock(*Kcb); + /* Return success for now */ return STATUS_SUCCESS; } @@ -1197,7 +1203,7 @@ CmpParseKey(IN PVOID ParseObject, if (!Kcb) ASSERT(FALSE); /* Dereference the parent and set the new one */ - //CmpDereferenceKeyControlBlock(ParentKcb); + CmpDereferenceKeyControlBlock(ParentKcb); ParentKcb = Kcb; } else @@ -1336,7 +1342,7 @@ CmpParseKey(IN PVOID ParseObject, /* Dereference the parent if it exists */ Quickie: - //if (ParentKcb) CmpDereferenceKeyControlBlock(ParentKcb); + if (ParentKcb) CmpDereferenceKeyControlBlock(ParentKcb); /* Unlock the registry */ CmpUnlockRegistry();