From 3e19ada6a96c6c8d9db7c97fa31d959f2c5171bd Mon Sep 17 00:00:00 2001 From: Jasen Date: Thu, 12 Sep 2024 11:05:40 +1200 Subject: [PATCH] Add null guard when calling TryGetDebugInformation --- .../Diagnostics/PortableExecutableReaderExtensions.cs | 6 ++++++ .../Diagnostics/PortableExecutableReaderExtensions.cs | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Mindscape.Raygun4Net.Core/Diagnostics/PortableExecutableReaderExtensions.cs b/Mindscape.Raygun4Net.Core/Diagnostics/PortableExecutableReaderExtensions.cs index 71f7c0da..3ab8ac2d 100644 --- a/Mindscape.Raygun4Net.Core/Diagnostics/PortableExecutableReaderExtensions.cs +++ b/Mindscape.Raygun4Net.Core/Diagnostics/PortableExecutableReaderExtensions.cs @@ -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); diff --git a/Mindscape.Raygun4Net.NetCore.Common/Diagnostics/PortableExecutableReaderExtensions.cs b/Mindscape.Raygun4Net.NetCore.Common/Diagnostics/PortableExecutableReaderExtensions.cs index b1d56302..af6d95b8 100644 --- a/Mindscape.Raygun4Net.NetCore.Common/Diagnostics/PortableExecutableReaderExtensions.cs +++ b/Mindscape.Raygun4Net.NetCore.Common/Diagnostics/PortableExecutableReaderExtensions.cs @@ -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);