fix bug in CmiCreateHiveFreeCellList when a cell has size 0 which leads to inifite...
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Sat, 3 Jun 2006 12:48:09 +0000 (12:48 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Sat, 3 Jun 2006 12:48:09 +0000 (12:48 +0000)
fix bug in CmiCreateTempHive where only a pointer was allocated for the first cell but not object itself

svn path=/trunk/; revision=22192

reactos/ntoskrnl/cm/regfile.c

index 66a680f..b5ecab8 100644 (file)
@@ -783,10 +783,24 @@ CmiCreateHiveFreeCellList(PREGISTRY_HIVE Hive)
 
              FreeOffset += FreeBlock->CellSize;
            }
-         else
+      else if (FreeBlock->CellSize < 0)
            {
              FreeOffset -= FreeBlock->CellSize;
            }
+      else
+         {
+#ifdef HIVE_CHECK
+         /* Check and eventually fix a hive */
+         Status = CmiCheckAndFixHive(Hive);
+         if (!NT_SUCCESS(Status))
+           {
+             DPRINT1("CmiCheckAndFixHive() failed (Status %lx)\n", Status);
+             return(Status);
+           }
+#else
+                break;
+#endif
+         }
        }
 
       BlockIndex += Bin->BinSize / REG_BLOCK_SIZE;
@@ -1164,7 +1178,7 @@ CmiCreateTempHive(PREGISTRY_HIVE *RegistryHive)
 
   /* Allocate hive block list */
   Hive->BlockList = ExAllocatePool (NonPagedPool,
-                                   sizeof(PBLOCK_LIST_ENTRY));
+                                   sizeof(BLOCK_LIST_ENTRY));
   if (Hive->BlockList == NULL)
     {
       DPRINT1 ("Failed to allocate hive block list\n");