Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Fix DecoderNLS.Convert to out the correct value for 'completed' (#27210)
Browse files Browse the repository at this point in the history
This is a complementary fix to https://github.com/dotnet/coreclr/issues/23020

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
  • Loading branch information
GrabYourPitchforks authored and safern committed Oct 21, 2019
1 parent fbc584c commit 713f2d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/Common/src/CoreLib/System/Text/DecoderNLS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,13 @@ public override unsafe int GetCharCount(byte* bytes, int count, bool flush)
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.

// Our data thingy are now full, we can return
completed = (bytesUsed == byteCount)
&& !this.HasState
&& (_fallbackBuffer is null || _fallbackBuffer.Remaining == 0);
}

public bool MustFlush => _mustFlush;
Expand Down
2 changes: 0 additions & 2 deletions src/Common/src/CoreLib/System/Text/EncoderNLS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int
completed = (charsUsed == charCount)
&& !this.HasState
&& (_fallbackBuffer is null || _fallbackBuffer.Remaining == 0);

// Our data thingys are now full, we can return
}

public Encoding Encoding
Expand Down

0 comments on commit 713f2d9

Please sign in to comment.