Skip to content

Commit

Permalink
Add conditional check for PDB location
Browse files Browse the repository at this point in the history
File.OpenRead can throw if pdb.PdbLocation is a directory.

This can happen if (for some reason) the pdb file is not found.
In which case PdbLocation will return the working directory, causing
File.OpenRead to throw.
  • Loading branch information
Lukas Kohl committed Jul 26, 2024
1 parent 65ce486 commit 66af743
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/BinaryParsers/PEBinary/PortableExecutable/PE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,11 @@ private bool TryGetPortablePdbMetadataReader(Pdb pdb, out MetadataReader pdbMeta
out MetadataReaderProvider pdbProvider,
out _))
{
pdbProvider = MetadataReaderProvider.FromPortablePdbStream(File.OpenRead(pdb.PdbLocation));
if (File.Exists(pdb.PdbLocation))
{
pdbProvider = MetadataReaderProvider.FromPortablePdbStream(File.OpenRead(pdb.PdbLocation));
}

if (pdbProvider == null)
{
pdbMetadataReader = null;
Expand Down

0 comments on commit 66af743

Please sign in to comment.