diff options
author | Levi Broderick <GrabYourPitchforks@users.noreply.github.com> | 2019-10-17 11:33:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-17 11:33:32 -0700 |
commit | 525f52122ad3919b6fb5df528533cc1039603d48 (patch) | |
tree | fef2ff747a5d55d1f2708ca778a5771b32995fe0 /src/System.Private.CoreLib | |
parent | b9c739940772f2745e4fdf6c2951fd7c7d3c7be0 (diff) | |
download | coreclr-525f52122ad3919b6fb5df528533cc1039603d48.tar.gz coreclr-525f52122ad3919b6fb5df528533cc1039603d48.tar.bz2 coreclr-525f52122ad3919b6fb5df528533cc1039603d48.zip |
Fix DecoderNLS.Convert to out the correct value for 'completed' (#27229)
Port https://github.com/dotnet/coreclr/pull/27210 to release/3.1
Diffstat (limited to 'src/System.Private.CoreLib')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Text/DecoderNLS.cs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Text/DecoderNLS.cs b/src/System.Private.CoreLib/shared/System/Text/DecoderNLS.cs index 8cb3fffe1b..a8153ffd90 100644 --- a/src/System.Private.CoreLib/shared/System/Text/DecoderNLS.cs +++ b/src/System.Private.CoreLib/shared/System/Text/DecoderNLS.cs @@ -207,9 +207,13 @@ namespace System.Text charsUsed = _encoding.GetChars(bytes, byteCount, chars, charCount, this); bytesUsed = _bytesUsed; - // Its completed if they've used what they wanted AND if they didn't want flush or if we are flushed - completed = (bytesUsed == byteCount) && (!flush || !this.HasState) && - (_fallbackBuffer == null || _fallbackBuffer.Remaining == 0); + // Per MSDN, "The completed output parameter indicates whether all the data in the input + // buffer was converted and stored in the output buffer." That means we've successfully + // consumed all the input _and_ there's no pending state or fallback data remaining to be output. + + completed = (bytesUsed == byteCount) + && !this.HasState + && (_fallbackBuffer is null || _fallbackBuffer.Remaining == 0); // Our data thingy are now full, we can return } |