Skip to content

Commit

Permalink
Add null guard when calling TryGetDebugInformation
Browse files Browse the repository at this point in the history
  • Loading branch information
JasenPalmer committed Sep 11, 2024
1 parent a7a45a4 commit 3e19ada
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public static PEReader GetFileSystemPEReader(string moduleName)

public static bool TryGetDebugInformation(this PEReader peReader, out PEDebugInformation debugInformation)
{
if (peReader is null)
{
debugInformation = null;
return false;
}

try
{
debugInformation = GetDebugInformation(peReader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ internal static class PortableExecutableReaderExtensions
}
}

public static bool TryGetDebugInformation(this PEReader peReader, out PEDebugInformation? debugInformation)
public static bool TryGetDebugInformation(this PEReader? peReader, out PEDebugInformation? debugInformation)
{
if (peReader is null)
{
debugInformation = null;
return false;
}

try
{
debugInformation = GetDebugInformation(peReader);
Expand Down

0 comments on commit 3e19ada

Please sign in to comment.