Skip to content

Commit b2aadf6

Browse files
Fix the order of highSurrogate and lowSurrogate.
1 parent 435d69c commit b2aadf6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Release/src/utilities/asyncrt_utils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,13 @@ std::string __cdecl conversions::utf16_to_utf8(const utf16string &w)
377377
// Check for high surrogate.
378378
if (src >= H_SURROGATE_START && src <= H_SURROGATE_END)
379379
{
380-
const auto highSurrogate = w[++index];
380+
const auto highSurrogate = src;
381+
++index;
381382
if (index == w.size())
382383
{
383384
throw std::range_error("UTF-16 string is missing low surrogate");
384385
}
385-
const auto lowSurrogate = src;
386+
const auto lowSurrogate = w[index];
386387
if (lowSurrogate < L_SURROGATE_START || lowSurrogate > L_SURROGATE_END)
387388
{
388389
throw std::range_error("UTF-16 string has invalid low surrogate");

0 commit comments

Comments
 (0)