From f710105b8b7ded04e5907aaf821bf0e3d662e5ee Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Mon, 3 Oct 2005 22:46:49 +0000 Subject: [PATCH] fixed a memory leak in RegDeleteTree() that could be caused when two threads attempt to delete the same tree simultaneously svn path=/trunk/; revision=18254 --- reactos/lib/advapi32/reg/reg.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/reactos/lib/advapi32/reg/reg.c b/reactos/lib/advapi32/reg/reg.c index 0e185938f85..bbba477e8b2 100644 --- a/reactos/lib/advapi32/reg/reg.c +++ b/reactos/lib/advapi32/reg/reg.c @@ -1466,7 +1466,15 @@ ReadFirstSubKey: } else if (Status2 == STATUS_NO_MORE_ENTRIES) { - ASSERT(newDelKeys == NULL); + /* in some race conditions where another thread would delete + the same tree at the same time, newDelKeys could actually + be != NULL! */ + if (newDelKeys != NULL) + { + RtlFreeHeap(ProcessHeap, + 0, + newDelKeys); + } break; } @@ -1555,7 +1563,7 @@ RegDeleteTreeW(IN HKEY hKey, NULL); Status = NtOpenKey(&SubKeyHandle, - DELETE | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, + DELETE | KEY_ENUMERATE_SUB_KEYS, &ObjectAttributes); if (!NT_SUCCESS(Status)) {