Author: tfaber
Date: Sun Apr 5 08:58:08 2015
New Revision: 67059
URL:
http://svn.reactos.org/svn/reactos?rev=67059&view=rev
Log:
[SERVICES]
- Free unknown groups when their reference count reaches zero
CORE-9480 #resolve
Modified:
trunk/reactos/base/system/services/database.c
trunk/reactos/base/system/services/groupdb.c
Modified: trunk/reactos/base/system/services/database.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/datab…
==============================================================================
--- trunk/reactos/base/system/services/database.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/database.c [iso-8859-1] Sun Apr 5 08:58:08 2015
@@ -416,8 +416,7 @@
ScmDereferenceServiceImage(lpService->lpImage);
/* Decrement the group reference counter */
- if (lpService->lpGroup)
- lpService->lpGroup->dwRefCount--;
+ ScmSetServiceGroup(lpService, NULL);
/* FIXME: SecurityDescriptor */
Modified: trunk/reactos/base/system/services/groupdb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/group…
==============================================================================
--- trunk/reactos/base/system/services/groupdb.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/groupdb.c [iso-8859-1] Sun Apr 5 08:58:08 2015
@@ -33,10 +33,25 @@
if (lpService->lpGroup != NULL)
{
- lpService->lpGroup->dwRefCount--;
-
- /* FIXME: What do we have to do when dwRefCount is 0? */
- }
+ ASSERT(lpService->lpGroup->dwRefCount != 0);
+ ASSERT(lpService->lpGroup->dwRefCount == (DWORD)-1 ||
+ lpService->lpGroup->dwRefCount < 10000);
+ if (lpService->lpGroup->dwRefCount != (DWORD)-1)
+ {
+ lpService->lpGroup->dwRefCount--;
+ if (lpService->lpGroup->dwRefCount == 0)
+ {
+ ASSERT(lpService->lpGroup->TagCount == 0);
+ ASSERT(lpService->lpGroup->TagArray == NULL);
+ RemoveEntryList(&lpService->lpGroup->GroupListEntry);
+ HeapFree(GetProcessHeap(), 0, lpService->lpGroup);
+ lpService->lpGroup = NULL;
+ }
+ }
+ }
+
+ if (lpGroupName == NULL)
+ return ERROR_SUCCESS;
GroupEntry = GroupListHead.Flink;
while (GroupEntry != &GroupListHead)