Skip to content

Commit c9f6830

Browse files
committed
NTFS: IndexData: RemoveEntry: Bugfix: IndexOutOfRangeException was thrown in some cases
1 parent 45e4377 commit c9f6830

File tree

1 file changed

+8
-1
lines changed
  • DiskAccessLibrary/FileSystems/NTFS/AttributeData

1 file changed

+8
-1
lines changed

DiskAccessLibrary/FileSystems/NTFS/AttributeData/IndexData.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,14 @@ public void RemoveEntry(byte[] key)
299299
if (leaf.IndexEntries.Count == 0)
300300
{
301301
int indexOfLeafPointer = pathToLeaf[pathToLeaf.Count - 1].Key;
302-
RemovePointer(pathToLeaf.GetRange(0, pathToLeaf.Count - 1), indexOfLeafPointer);
302+
if (pathToLeaf.Count > 1)
303+
{
304+
RemovePointer(pathToLeaf.GetRange(0, pathToLeaf.Count - 1), indexOfLeafPointer);
305+
}
306+
else
307+
{
308+
RemovePointerFromRoot(indexOfLeafPointer);
309+
}
303310
DeallocateIndexRecord(leafRecordIndex);
304311
}
305312
}

0 commit comments

Comments
 (0)