Fix crash when changing text with UTF-8 chars

The code left a byte from the previous text in CEdit UI control if
the new text is shorter than the old one. So an exception was thrown
because it's an invalid UTF-8 byte.
pyro-refactor
MrSimbax 2020-07-25 21:20:19 +02:00
parent 93f3abee1a
commit fd36ff3840
1 changed files with 2 additions and 0 deletions

View File

@ -1299,7 +1299,9 @@ void CEdit::SetText(const std::string& text, bool bNew)
if( m_len >= GetMaxChar() ) m_len = GetMaxChar();
m_text.resize( m_len + 1, '\0' );
m_text[m_len] = '\0';
m_format.resize( m_len + 1, m_fontType );
m_format[m_len] = m_fontType;
font = m_fontType;
j = 0;