diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index 166af32cd27..fa25a7092e3 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -220,7 +220,7 @@ threadmbcinfo* create_mbcinfo(int cp, LCID lcid, threadmbcinfo *old_mbcinfo) WORD chartypes[256]; char bufA[256]; WCHAR bufW[256], lowW[256], upW[256]; - int charcount; + int charcount, maxchar; int ret; int i; @@ -288,7 +288,7 @@ threadmbcinfo* create_mbcinfo(int cp, LCID lcid, threadmbcinfo *old_mbcinfo) bytes += 2; } - if (cpi.MaxCharSize > 1) + if (cpi.MaxCharSize == 2) { /* trail bytes not available through kernel32 but stored in a structure in msvcrt */ struct cp_extra_info_t *cpextra = g_cpextrainfo; @@ -316,10 +316,12 @@ threadmbcinfo* create_mbcinfo(int cp, LCID lcid, threadmbcinfo *old_mbcinfo) else mbcinfo->ismbcodepage = 0; + maxchar = (newcp == CP_UTF8) ? 128 : 256; + /* we can't use GetStringTypeA directly because we don't have a locale - only a code page */ charcount = 0; - for (i = 0; i < 256; i++) + for (i = 0; i < maxchar; i++) if (!(mbcinfo->mbctype[i + 1] & _M1)) bufA[charcount++] = i; @@ -335,7 +337,7 @@ threadmbcinfo* create_mbcinfo(int cp, LCID lcid, threadmbcinfo *old_mbcinfo) LCMapStringW(lcid, LCMAP_UPPERCASE, bufW, charcount, upW, charcount); charcount = 0; - for (i = 0; i < 256; i++) + for (i = 0; i < maxchar; i++) if (!(mbcinfo->mbctype[i + 1] & _M1)) { if (chartypes[charcount] & C1_UPPER) @@ -359,7 +361,7 @@ threadmbcinfo* create_mbcinfo(int cp, LCID lcid, threadmbcinfo *old_mbcinfo) } charcount = 0; - for (i = 0; i < 256; i++) + for (i = 0; i < maxchar; i++) { if(!(mbcinfo->mbctype[i + 1] & _M1)) {