Skip to content

Commit

Permalink
Throw if root directory entry is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-visionaid committed Oct 7, 2024
1 parent 4a58717 commit 493f0d5
Showing 1 changed file with 5 additions and 30 deletions.
35 changes: 5 additions & 30 deletions sources/OpenMcdf/CompoundFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1502,44 +1502,19 @@ internal List<Sector> GetSectorChain(int secID, SectorType chainType)

internal RBTree GetChildrenTree(IDirectoryEntry entry)
{
RBTree bst = new RBTree();
RBTree bst = new();

// Load children from their original tree.
LoadChildren(bst, entry);
//bst = DoLoadChildrenTrusted(directoryEntries[sid]);

//bst.Print();
//bst.Print();
//Trace.WriteLine("#### After rethreading");

return bst;
}

private RBTree DoLoadChildrenTrusted(IDirectoryEntry de)
{
RBTree bst = null;

if (de.Child != DirectoryEntry.NOSTREAM)
if (entry.Child != DirectoryEntry.NOSTREAM)
{
bst = new RBTree(directoryEntries[de.Child]);
IDirectoryEntry child = directoryEntries[entry.Child];
List<int> levelSIDs = new List<int>();
LoadChildren(bst, child, levelSIDs);
}

return bst;
}

private void LoadChildren(RBTree bst, IDirectoryEntry de)
{
if (de.Child != DirectoryEntry.NOSTREAM)
{
IDirectoryEntry child = directoryEntries[de.Child];
if (child.StgType != StgType.StgInvalid)
{
List<int> levelSIDs = new List<int>();
LoadChildren(bst, child, levelSIDs);
}
}
}

private static void NullifyChildNodes(IDirectoryEntry de)
{
de.Parent = null;
Expand Down

0 comments on commit 493f0d5

Please sign in to comment.