From 630b1b2eb319958f38a0b2b464dd9e70d831f6a7 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 25 Sep 2004 20:53:29 +0000 Subject: [PATCH] - Fix usage of RtlFindSetBits and loops in CmiStartLogUpdate and CmiStartHiveUpdate. svn path=/trunk/; revision=11054 --- reactos/ntoskrnl/cm/regfile.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/reactos/ntoskrnl/cm/regfile.c b/reactos/ntoskrnl/cm/regfile.c index bebaf3bbefc..ac5f99b7e9f 100644 --- a/reactos/ntoskrnl/cm/regfile.c +++ b/reactos/ntoskrnl/cm/regfile.c @@ -1397,6 +1397,7 @@ CmiStartLogUpdate(PREGISTRY_HIVE RegistryHive) PUCHAR Buffer; PUCHAR Ptr; ULONG BlockIndex; + ULONG LastIndex; PVOID BlockPtr; NTSTATUS Status; @@ -1486,13 +1487,13 @@ CmiStartLogUpdate(PREGISTRY_HIVE RegistryHive) /* Write dirty blocks */ FileOffset.QuadPart = (ULONGLONG)BufferSize; BlockIndex = 0; - while (TRUE) + while (BlockIndex < RegistryHive->BlockListSize) { + LastIndex = BlockIndex; BlockIndex = RtlFindSetBits(&RegistryHive->DirtyBitMap, 1, BlockIndex); - if ((BlockIndex == (ULONG)-1) || - (BlockIndex >= RegistryHive->BlockListSize)) + if (BlockIndex == (ULONG)-1 || BlockIndex < LastIndex) { DPRINT("No more set bits\n"); Status = STATUS_SUCCESS; @@ -1771,6 +1772,7 @@ CmiStartHiveUpdate(PREGISTRY_HIVE RegistryHive) HANDLE FileHandle; LARGE_INTEGER FileOffset; ULONG BlockIndex; + ULONG LastIndex; PVOID BlockPtr; NTSTATUS Status; @@ -1823,13 +1825,13 @@ CmiStartHiveUpdate(PREGISTRY_HIVE RegistryHive) } BlockIndex = 0; - while (TRUE) + while (BlockIndex < RegistryHive->BlockListSize) { + LastIndex = BlockIndex; BlockIndex = RtlFindSetBits(&RegistryHive->DirtyBitMap, 1, BlockIndex); - if ((BlockIndex == (ULONG)-1) || - (BlockIndex >= RegistryHive->BlockListSize)) + if (BlockIndex == (ULONG)-1 || BlockIndex < LastIndex) { DPRINT("No more set bits\n"); Status = STATUS_SUCCESS;