diff options
author | Levi Broderick <GrabYourPitchforks@users.noreply.github.com> | 2019-04-01 14:25:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-01 14:25:55 -0700 |
commit | 8c78e8597eb90ec133c7a09567ff0a8cd25d7c78 (patch) | |
tree | 2ec4e5908e4f12fe9a23efd882fb79a6eca3e571 | |
parent | d686be5513cd09426704eb576858411d1e736d0d (diff) | |
download | coreclr-8c78e8597eb90ec133c7a09567ff0a8cd25d7c78.tar.gz coreclr-8c78e8597eb90ec133c7a09567ff0a8cd25d7c78.tar.bz2 coreclr-8c78e8597eb90ec133c7a09567ff0a8cd25d7c78.zip |
Fix bad Debug.Assert statements in UTF-8 processing (#23627)
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Text/Unicode/Utf8.cs | 8 | ||||
-rw-r--r-- | src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs | 3 |
2 files changed, 4 insertions, 7 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Text/Unicode/Utf8.cs b/src/System.Private.CoreLib/shared/System/Text/Unicode/Utf8.cs index 9e6f245c10..6c8197d22b 100644 --- a/src/System.Private.CoreLib/shared/System/Text/Unicode/Utf8.cs +++ b/src/System.Private.CoreLib/shared/System/Text/Unicode/Utf8.cs @@ -106,8 +106,8 @@ namespace System.Text.Unicode numCharsRead = originalSourceLength - source.Length; numBytesWritten = originalDestinationLength - destination.Length; - Debug.Assert(numCharsRead < originalSourceLength || status != OperationStatus.Done, - "Cannot report OperationStatus.Done if we haven't consumed the entire input buffer."); + Debug.Assert((status == OperationStatus.Done) == (numCharsRead == originalSourceLength), + "Should report OperationStatus.Done if and only if we've consumed the entire input buffer."); return status; } @@ -189,8 +189,8 @@ namespace System.Text.Unicode numBytesRead = originalSourceLength - source.Length; numCharsWritten = originalDestinationLength - destination.Length; - Debug.Assert(numBytesRead < originalSourceLength || status != OperationStatus.Done, - "Cannot report OperationStatus.Done if we haven't consumed the entire input buffer."); + Debug.Assert((status == OperationStatus.Done) == (numBytesRead == originalSourceLength), + "Should report OperationStatus.Done if and only if we've consumed the entire input buffer."); return status; } diff --git a/src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs b/src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs index 6e5209962f..9ca72f1729 100644 --- a/src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs +++ b/src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs @@ -4,8 +4,6 @@ using System.Diagnostics; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Text; namespace System { @@ -21,7 +19,6 @@ namespace System Debug.Assert(length >= 0, "Length cannot be negative."); Debug.Assert(startIndex + length <= this.Length, "StartIndex and Length cannot point beyond the end of the string."); - Debug.Assert(startIndex != 0 && startIndex != this.Length, "Caller should handle StartIndex boundary conditions."); Debug.Assert(length != 0 && length != this.Length, "Caller should handle Length boundary conditions."); Utf8String newString = FastAllocate(length); |