Fix invalid memory read in wxMSW wxTextCtrl::GetLineText()

Don't read before the start of the buffer when getting the text of an
empty line, this was (correctly) flagged as heap error by address
sanitizer.
This commit is contained in:
Vadim Zeitlin
2020-11-28 16:35:03 +01:00
parent 7dbcbad7c6
commit ef9161861d

View File

@@ -1928,7 +1928,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
// remove the '\n' at the end, if any (this is how this function is
// supposed to work according to the docs)
if ( buf[len - 1] == wxT('\n') )
if ( len && buf[len - 1] == wxT('\n') )
{
len--;
}