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:
committed by
Vadim Zeitlin
parent
e9a836c9dc
commit
e6a6748eaf
@@ -5038,6 +5038,7 @@ wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
|
|||||||
tr.lpstrText = buf.data();
|
tr.lpstrText = buf.data();
|
||||||
tr.chrg.cpMin = startPos;
|
tr.chrg.cpMin = startPos;
|
||||||
tr.chrg.cpMax = endPos;
|
tr.chrg.cpMax = endPos;
|
||||||
|
tr.lpstrText[0] = '\0'; // initialize with 0 in case the range is invalid
|
||||||
SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr);
|
SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@@ -744,6 +744,7 @@ wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
|
|||||||
tr.lpstrText = buf.data();
|
tr.lpstrText = buf.data();
|
||||||
tr.chrg.cpMin = startPos;
|
tr.chrg.cpMin = startPos;
|
||||||
tr.chrg.cpMax = endPos;
|
tr.chrg.cpMax = endPos;
|
||||||
|
tr.lpstrText[0] = '\0'; // initialize with 0 in case the range is invalid
|
||||||
SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr);
|
SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user