]> git.saurik.com Git - wxWidgets.git/commitdiff
fix for bug #29 (blank lines in GetLineText)
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 25 Feb 2000 00:03:29 +0000 (00:03 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 25 Feb 2000 00:03:29 +0000 (00:03 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6272 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/textctrl.cpp

index c23b395533ab88bb1fcf3ff5c77aded55ed85e3b..c4969c93942f6fc51158c2cd32afcc6acbcc0df7 100644 (file)
@@ -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);