From 488fe1feb6e8924cb8a2fddc633e1198d16e5345 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 25 Feb 2000 00:03:29 +0000 Subject: [PATCH] fix for bug #29 (blank lines in GetLineText) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6272 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/textctrl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index c23b395533..c4969c9394 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -807,7 +807,16 @@ int wxTextCtrl::GetLineLength(long lineNo) const wxString wxTextCtrl::GetLineText(long lineNo) const { + // TODO this should probably be optimized by using GetWriteBuf() + size_t len = (size_t)GetLineLength(lineNo) + 1; + if ( len < sizeof(WORD) ) + { + // there must be at least enough place for the length WORD in the + // buffer + len += sizeof(WORD); + } + char *buf = (char *)malloc(len); *(WORD *)buf = len; int noChars = (int)SendMessage(GetHwnd(), EM_GETLINE, lineNo, (LPARAM)buf); -- 2.45.2