diff --git a/src/libraries/System.Private.CoreLib/src/System/String.cs b/src/libraries/System.Private.CoreLib/src/System/String.cs index 9489b7b0b3c06a..9e4916749e9ee6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/String.cs +++ b/src/libraries/System.Private.CoreLib/src/System/String.cs @@ -531,7 +531,8 @@ public static bool IsNullOrWhiteSpace([NotNullWhen(false)] string? value) internal static string Alloc(int length, out Span resultSpan) { string result = FastAllocateString(length); - resultSpan = new Span(ref result._firstChar, result._stringLength); + Debug.Assert(result.Length == length); + resultSpan = new Span(ref result._firstChar, length); return result; }