Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5859 (Melt crashes melting MSIs with elevated privileges) #469

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
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