Fix UTF8 encoding fallback index (#18387)
authorTarek Mahmoud Sayed <tarekms@microsoft.com>
Mon, 11 Jun 2018 19:23:26 +0000 (12:23 -0700)
committerGitHub <noreply@github.com>
Mon, 11 Jun 2018 19:23:26 +0000 (12:23 -0700)
commitd093d9a9c83182f92a84c05af89e4859611d095a
tree1f54f617e3df3066e4c6cb7e6f2f2907003629b4
parent2bfc551e240198d88d79f5425d783da31872e8f7
Fix UTF8 encoding fallback index (#18387)

* Fix UTF8 encoding fallback index

When falling back in UTF8 decoding, we’ll call the DecoderFallbackBuffer.InternalFallback method which takes a pointer to the source bytes pointer which point to where we have progressed inside the source bytes. The problem is before calling DecoderFallbackBuffer.InternalFallback we call GetBytesUnknown which can adjust the source byte pointer and DecoderFallbackBuffer.InternalFallback need to be called with the pointer before the adjustment. The fix is simply storing the original pointer value of the source byte pointer before calling GetBytesUnknown and then pass the stored original pointer to DecoderFallbackBuffer.InternalFallback instead of the adjusted source byte pointer

* Fix the comment
src/System.Private.CoreLib/shared/System/Text/UTF8Encoding.cs