Fixed a serious bug in windows/utf16.cpp that went unnoticed for this long: we wanted utf16UTF8Count(), not utf16RuneCount(), in toUTF8(); any non-ASCII text had the wrong number of bytes, and thus random heap corruption. The string "鎿嶄綔鎴愬姛瀹屾垚銆" (taken from the completely unrelated #337) and the Set Button Text button was enough to trigger this.

This commit is contained in:
Pietro Gagliardi 2018-04-15 23:10:11 -04:00
parent c3992cc647
commit fcc26ab9a9
1 changed files with 1 additions and 1 deletions

View File

@ -32,7 +32,7 @@ char *toUTF8(const WCHAR *wstr)
if (*wstr == L'\0') // empty string if (*wstr == L'\0') // empty string
return emptyUTF8(); return emptyUTF8();
n = uiprivUTF16RuneCount(wstr, 0); n = uiprivUTF16UTF8Count(wstr, 0);
str = (char *) uiprivAlloc((n + 1) * sizeof (char), "char[]"); str = (char *) uiprivAlloc((n + 1) * sizeof (char), "char[]");
sp = str; sp = str;
while (*wstr) { while (*wstr) {