Skip to content

Commit 585f556

Browse files
GrabYourPitchforksmarek-safar
authored andcommitted
Add missing check to 3-byte processing logic
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
1 parent 51bac63 commit 585f556

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

netcore/System.Private.CoreLib/shared/System/Text/Unicode/Utf8Utility.Transcoding.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,10 @@ public static OperationStatus TranscodeToUtf16(byte* pInputBuffer, int inputLeng
513513
// fail, and redirect control flow to the error handling logic at the very end of this method.
514514

515515
uint secondDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer + 3);
516-
if (((secondDWord & 0x0000_200Fu) != 0) && (((secondDWord - 0x0000_200Du) & 0x0000_200Fu) != 0))
516+
517+
if (UInt32BeginsWithUtf8ThreeByteMask(secondDWord)
518+
&& ((secondDWord & 0x0000_200Fu) != 0)
519+
&& (((secondDWord - 0x0000_200Du) & 0x0000_200Fu) != 0))
517520
{
518521
// combinedQWord = [ 1110ZZZZ 10YYYYYY 10XXXXXX ######## | 1110zzzz 10yyyyyy 10xxxxxx ######## ], where xyz are from first DWORD, XYZ are from second DWORD
519522
ulong combinedQWord = ((ulong)BinaryPrimitives.ReverseEndianness(secondDWord) << 32) | BinaryPrimitives.ReverseEndianness(thisDWord);

0 commit comments

Comments
 (0)