Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tracer/src/Datadog.Trace/Iast/DefaultTaintedMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void Clear()

private int IndexObject(object objectStored)
{
return Index(PositiveHashCode(objectStored.GetHashCode()));
return Index(PositiveHashCode(IastUtils.IdentityHashCode(objectStored)));
}

private int PositiveHashCode(int hash)
Expand Down
15 changes: 14 additions & 1 deletion tracer/src/Datadog.Trace/Iast/IastUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,20 @@ private static int GetHash<T>(T element)

public static int IdentityHashCode(object item)
{
return (item?.GetHashCode() ?? 0);
if (item == null)
{
return 0;
}

try
{
return item.GetHashCode();
}
catch
{
// Seen this that it appears some customer objects have overrode GetHashCode and throw
return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(item);
}
}

public static Range[] GetRangesForString(string stringValue, Source source)
Expand Down
Loading