diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 1e4c609889..f630177258 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -5038,6 +5038,7 @@ wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos) tr.lpstrText = buf.data(); tr.chrg.cpMin = startPos; tr.chrg.cpMax = endPos; + tr.lpstrText[0] = '\0'; // initialize with 0 in case the range is invalid SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr); return buf; } diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index f2a1dc5fb7..3ef93376f8 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -744,6 +744,7 @@ wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos) tr.lpstrText = buf.data(); tr.chrg.cpMin = startPos; tr.chrg.cpMax = endPos; + tr.lpstrText[0] = '\0'; // initialize with 0 in case the range is invalid SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr); return buf; }