diff --git a/tracer/src/Datadog.Trace/Iast/StackWalker.cs b/tracer/src/Datadog.Trace/Iast/StackWalker.cs index ff81a686fdf8..e34e87275ab6 100644 --- a/tracer/src/Datadog.Trace/Iast/StackWalker.cs +++ b/tracer/src/Datadog.Trace/Iast/StackWalker.cs @@ -55,7 +55,8 @@ public static StackTrace GetStackTrace() public static bool TryGetFrame(StackTrace stackTrace, out StackFrame? targetFrame) { targetFrame = null; - foreach (var frame in stackTrace.GetFrames()) + var frames = stackTrace.GetFrames() ?? []; + foreach (var frame in frames) { var declaringType = frame?.GetMethod()?.DeclaringType;