diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index d8662c0554..6e0aee5ae5 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -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--; }