Skip to content

Commit

Permalink
Osk: Correct UCS2 conversion.
Browse files Browse the repository at this point in the history
String end was calculated incorrectly.
  • Loading branch information
unknownbrackets committed Mar 23, 2020
1 parent edbd018 commit b979505
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ext/native/util/text/utf8.cpp
Expand Up @@ -495,11 +495,11 @@ static size_t ConvertUTF8ToUCS2Internal(char16_t *dest, size_t destSize, const s
}

// No ++ to not count the terminal in length.
if (dest < destEnd) {
*dest = 0;
if (destw < destEnd) {
*destw = 0;
}

return dest - orig;
return destw - orig;
}

void ConvertUTF8ToUCS2(char16_t *dest, size_t destSize, const std::string &source) {
Expand Down Expand Up @@ -548,6 +548,7 @@ static size_t ConvertUTF8ToWStringInternal(wchar_t *dest, size_t destSize, const
}
destw += UTF16LE::encode(destw, c);
}
dest = (wchar_t *)destw;
} else {
while (char32_t c = utf.next()) {
if (dest + 1 >= destEnd) {
Expand Down

1 comment on commit b979505

@hrydgard
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh, good catch!

Please sign in to comment.