Skip to content

Commit 60d67b8

Browse files
authored
Ensure rented array is always returned (#104223)
1 parent 53a8a01 commit 60d67b8

File tree

1 file changed

+3
-0
lines changed
  • src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics

1 file changed

+3
-0
lines changed

src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/Measurement.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ public Measurement(T value, params ReadOnlySpan<KeyValuePair<string, object?>> t
115115
}
116116

117117
if (count == 0)
118+
{
119+
ArrayPool<KeyValuePair<string, object?>>.Shared.Return(array);
118120
return Instrument.EmptyTags;
121+
}
119122

120123
result = new KeyValuePair<string, object?>[count];
121124
array.AsSpan().Slice(0, count).CopyTo(result.AsSpan());

0 commit comments

Comments
 (0)