Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions src/tools/wix/Pdb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,16 @@ public static Pdb Load(string path, bool suppressVersionCheck, bool suppressSche
internal static Pdb Load(Stream stream, Uri uri, bool suppressVersionCheck, bool suppressSchema)
{
XmlReader reader = null;
TempFileCollection tempFileCollection = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not critical, but I would recommend a try/finally wherein you dispose of the TempFileCollection if it is not assigned to pdb.Output.TempFiles

string cabPath = null;

// look for the Microsoft cabinet file header and save the cabinet data if found
if ('M' == stream.ReadByte() && 'S' == stream.ReadByte() && 'C' == stream.ReadByte() && 'F' == stream.ReadByte())
{
long cabFileSize = 0;
byte[] offsetBuffer = new byte[4];
using (TempFileCollection tempFileCollection = new TempFileCollection())
{
cabPath = tempFileCollection.AddExtension("cab", true);
}
tempFileCollection = new TempFileCollection();
cabPath = tempFileCollection.AddExtension("cab", false);

// skip the header checksum
stream.Seek(4, SeekOrigin.Current);
Expand Down Expand Up @@ -138,16 +137,7 @@ internal static Pdb Load(Stream stream, Uri uri, bool suppressVersionCheck, bool
}

Pdb pdb = Parse(reader, suppressVersionCheck);

if (null != cabPath)
{
if (pdb.Output.TempFiles == null)
{
pdb.Output.TempFiles = new TempFileCollection();
}

pdb.Output.TempFiles.AddFile(cabPath, false);
}
pdb.Output.TempFiles = tempFileCollection;

return pdb;
}
Expand Down