From 3e19ada6a96c6c8d9db7c97fa31d959f2c5171bd Mon Sep 17 00:00:00 2001 From: Jasen Date: Thu, 12 Sep 2024 11:05:40 +1200 Subject: [PATCH 1/2] 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); From e0dd16a451455f039e65b0f87aed95605649fa3b Mon Sep 17 00:00:00 2001 From: Jasen Date: Thu, 12 Sep 2024 11:41:11 +1200 Subject: [PATCH 2/2] Updated change log --- CHANGE-LOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGE-LOG.md b/CHANGE-LOG.md index 120db4cc..ab20440d 100644 --- a/CHANGE-LOG.md +++ b/CHANGE-LOG.md @@ -1,5 +1,9 @@ # Full Change Log for Raygun4Net.* packages +### v11.1.1 +- Prevented a null reference exception from being thrown after a PortableExecutable (PE) fails to be loaded from disk + - See: https://github.com/MindscapeHQ/raygun4net/pull/544 + ### v11.1.0 - Fix issue with `RaygunClientBase` where `SendInBackground` deferred building the message until late, losing HttpContext - See: https://github.com/MindscapeHQ/raygun4net/pull/540