diff --git a/src/System.Management.Automation/utils/StringUtil.cs b/src/System.Management.Automation/utils/StringUtil.cs index 6bdedd03a3..8daf31866d 100644 --- a/src/System.Management.Automation/utils/StringUtil.cs +++ b/src/System.Management.Automation/utils/StringUtil.cs @@ -202,7 +202,7 @@ namespace System.Management.Automation.Internal } // If the number of copied non-escape-sequence characters has reached the specified length, done copying. - if (offset == length) + if (copyStarted && offset == length) { break; }