Jacek Caban (@jacek) commented about dlls/kernelbase/path.c:
+ memcpy(buf + 2, src + 2, 2 * sizeof(WCHAR)); + StrToIntExW(buf, STIF_SUPPORT_HEX, &ih); + /* Check if it is a valid continuation byte. */ + if (*(src + 1) == '%' && (ih & 0xc0) == 0x80) + { + utf8_buf[i] = ih; + src += 3; + } + else + { + utf8_len = i; + break; + } + } + + utf16_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, utf8_buf, utf8_len, utf16_buf, 5); 5 is ARRAY_SIZE(utf16_buf). Also now that you don't need to null-terminate it, 4 should be enough.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/585#note_41330