From fcc26ab9a97ce14dc1bc3334e8901683b1aacc85 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 15 Apr 2018 23:10:11 -0400 Subject: [PATCH] =?UTF-8?q?Fixed=20a=20serious=20bug=20in=20windows/utf16.?= =?UTF-8?q?cpp=20that=20went=20unnoticed=20for=20this=20long:=20we=20wante?= =?UTF-8?q?d=20utf16UTF8Count(),=20not=20utf16RuneCount(),=20in=20toUTF8()?= =?UTF-8?q?;=20any=20non-ASCII=20text=20had=20the=20wrong=20number=20of=20?= =?UTF-8?q?bytes,=20and=20thus=20random=20heap=20corruption.=20The=20strin?= =?UTF-8?q?g=20"=E9=8E=BF=E5=B6=84=E7=B6=94=E9=8E=B4=E6=84=AC=E5=A7=9B?= =?UTF-8?q?=E7=80=B9=E5=B1=BE=E5=9E=9A=E9=8A=86"=20(taken=20from=20the=20c?= =?UTF-8?q?ompletely=20unrelated=20#337)=20and=20the=20Set=20Button=20Text?= =?UTF-8?q?=20button=20was=20enough=20to=20trigger=20this.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- windows/utf16.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/utf16.cpp b/windows/utf16.cpp index b9e57599..131759e9 100644 --- a/windows/utf16.cpp +++ b/windows/utf16.cpp @@ -32,7 +32,7 @@ char *toUTF8(const WCHAR *wstr) if (*wstr == L'\0') // empty string return emptyUTF8(); - n = uiprivUTF16RuneCount(wstr, 0); + n = uiprivUTF16UTF8Count(wstr, 0); str = (char *) uiprivAlloc((n + 1) * sizeof (char), "char[]"); sp = str; while (*wstr) {