diff --git a/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs index a77458f78c..57f2c59d57 100644 --- a/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs +++ b/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs @@ -213,7 +213,7 @@ public static class AbpStringExtensions var replaceLength = replace.Length; var newLength = str.Length - searchLength + replaceLength; - Span buffer = stackalloc char[newLength]; + Span buffer = newLength <= 1024 ? stackalloc char[newLength] : new char[newLength]; // Copy the part of the original string before the search term str.AsSpan(0, pos).CopyTo(buffer);