Fix wxStyledTextCtrl::GetTextRangeRaw() for invalid positions

Don't return garbage if the input positions are out of range, just return an
empty string in this case.
This commit is contained in:
Paul Kulchenko
2016-05-23 21:37:21 -07:00
committed by Vadim Zeitlin
parent e9a836c9dc
commit e6a6748eaf
2 changed files with 2 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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;
}