From ef9161861dbc728bd540e9c5a9a4882017828679 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 28 Nov 2020 16:35:03 +0100 Subject: [PATCH] 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. --- src/msw/textctrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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--; }