diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 66f161d26f..bfa51d3001 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -3691,9 +3691,9 @@ void wxStyledTextCtrl::SetTextRaw(const char* text) wxCharBuffer wxStyledTextCtrl::GetTextRaw() { - int len = GetTextLength(); - wxCharBuffer buf(len); - SendMsg(SCI_GETTEXT, len, (long)buf.data()); + int len = GetTextLength(); + wxCharBuffer buf(len); // adds 1 for NUL automatically + SendMsg(SCI_GETTEXT, len + 1, (long)buf.data()); return buf; } diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 9ce33cd2a6..45f5db364b 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -694,9 +694,9 @@ void wxStyledTextCtrl::SetTextRaw(const char* text) wxCharBuffer wxStyledTextCtrl::GetTextRaw() { - int len = GetTextLength(); - wxCharBuffer buf(len); - SendMsg(SCI_GETTEXT, len, (long)buf.data()); + int len = GetTextLength(); + wxCharBuffer buf(len); // adds 1 for NUL automatically + SendMsg(SCI_GETTEXT, len + 1, (long)buf.data()); return buf; }