Switch to fallback earlier if the input is not valid UTF-8 prefix

This commit is contained in:
Pavel Tyunin
2020-09-29 15:35:53 +03:00
parent bc838b4773
commit b3eff48e28
4 changed files with 25 additions and 4 deletions

View File

@@ -313,7 +313,7 @@ wxConvAuto::ToWChar(wchar_t *dst, size_t dstLen,
// to the fall-back conversion in this case as it would prevent us from
// decoding UTF-8 input when fed it byte by byte, as done by
// wxTextInputStream, for example
if ( srcLen < m_conv->GetMaxCharLen() )
if ( srcLen < m_conv->GetMaxCharLen() && wxIsUTF8Prefix(src, srcLen) )
return wxCONV_FAILED;
// if the conversion failed but we didn't really detect anything and