From 38a09f9c7bb2b29287bb24dc9cb7053ca0c5303c Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Wed, 16 Mar 2016 04:30:39 +0100 Subject: [PATCH] services: Hold scmdatabase lock while checking marked_for_delete. Signed-off-by: Sebastian Lackner Signed-off-by: Alexandre Julliard --- programs/services/services.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/programs/services/services.c b/programs/services/services.c index 78baaf2a51d..9f7e889ad83 100644 --- a/programs/services/services.c +++ b/programs/services/services.c @@ -456,13 +456,15 @@ struct service_entry *scmdatabase_find_service_by_displayname(struct scmdatabase void release_service(struct service_entry *service) { + struct scmdatabase *db = service->db; + + scmdatabase_lock(db); if (InterlockedDecrement(&service->ref_count) == 0 && is_marked_for_delete(service)) { - scmdatabase_lock(service->db); - scmdatabase_remove_service(service->db, service); - scmdatabase_unlock(service->db); + scmdatabase_remove_service(db, service); free_service_entry(service); } + scmdatabase_unlock(db); } static DWORD scmdatabase_create(struct scmdatabase **db)