Skip to content

Commit d111595

Browse files
Mike McLaughlindirecthex
authored andcommitted
Fix issue 98506 - Excessive exceptions generated in StackTraceSymbols (#105530)
* Fix issue 98506 - Excessive exceptions generated in StackTraceSymbols * Code review feedback
1 parent 0b1f89a commit d111595

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/libraries/System.Diagnostics.StackTrace/src/System/Diagnostics/StackTraceSymbols.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ internal void GetSourceLineInfo(Assembly assembly, string assemblyPath, IntPtr l
5858
sourceLine = 0;
5959
sourceColumn = 0;
6060

61-
MetadataReader? reader = TryGetReader(assembly, assemblyPath, loadedPeAddress, loadedPeSize, isFileLayout, inMemoryPdbAddress, inMemoryPdbSize);
62-
if (reader != null)
61+
Handle handle = MetadataTokens.Handle(methodToken);
62+
if (!handle.IsNil && handle.Kind == HandleKind.MethodDefinition)
6363
{
64-
Handle handle = MetadataTokens.Handle(methodToken);
65-
66-
if (handle.Kind == HandleKind.MethodDefinition)
64+
MetadataReader? reader = TryGetReader(assembly, assemblyPath, loadedPeAddress, loadedPeSize, isFileLayout, inMemoryPdbAddress, inMemoryPdbSize);
65+
if (reader != null)
6766
{
6867
MethodDebugInformationHandle methodDebugHandle = ((MethodDefinitionHandle)handle).ToDebugInformationHandle();
6968
MethodDebugInformation methodInfo = reader.GetMethodDebugInformation(methodDebugHandle);

0 commit comments

Comments
 (0)