Skip to content

Commit

Permalink
[ASM] iast: Fix for NullReferenceException in Stacktrace Walker (#6326)
Browse files Browse the repository at this point in the history
## Summary of changes

In .NET Framework the `GetFrames()` method can return null.

## Reason for change

Bug detected in telemetry ([Error Tracking
case](https://app.datadoghq.com/error-tracking?query=service%3Ainstrumentation-telemetry-data%20%40lib_language%3Adotnet%20%40tracer_version%3A3.6.0.0&fromUser=false&issue_states=&issueId=4ddc4722-7f47-11ef-afd5-da7ad0900002&refresh_mode=sliding&source=all&view=spans&from_ts=1732196777908&to_ts=1732211177908&live=true)).

## Implementation details

Create a null array when the method `GetFrames()` return null in .NET
Framework.
  • Loading branch information
e-n-0 authored Nov 21, 2024
1 parent 3b655e1 commit fb950f7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tracer/src/Datadog.Trace/Iast/StackWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit fb950f7

Please sign in to comment.