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:
parent
c3992cc647
commit
fcc26ab9a9
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue