Skip to content

Commit

Permalink
scintilla: Fix invalid memory access in MoveSelectedLines
Browse files Browse the repository at this point in the history
Fixes geany#2066.

X-Scintilla-Commit-ID: df5c32512d3d6b71ee6138c709b392258c3a1991,
                       25a0367e9349c8475c619a054af7bf1daf15b04c
X-Scintilla-Bug-ID: https://sourceforge.net/p/scintilla/bugs/2078/
  • Loading branch information
b4n committed Apr 27, 2019
1 parent 44c26ad commit d551765
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scintilla/src/Editor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,10 @@ void Editor::VerticalCentreCaret() {

void Editor::MoveSelectedLines(int lineDelta) {

if (sel.IsRectangular()) {
return;
}

// if selection doesn't start at the beginning of the line, set the new start
Sci::Position selectionStart = SelectionStart().Position();
const Sci::Line startLine = pdoc->SciLineFromPosition(selectionStart);
Expand Down Expand Up @@ -1042,7 +1046,6 @@ void Editor::MoveSelectedLines(int lineDelta) {
SelectionText selectedText;
CopySelectionRange(&selectedText);

Sci::Position selectionLength = SelectionRange(selectionStart, selectionEnd).Length();
const Point currentLocation = LocationFromPosition(CurrentPosition());
const Sci::Line currentLine = LineFromLocation(currentLocation);

Expand All @@ -1055,7 +1058,7 @@ void Editor::MoveSelectedLines(int lineDelta) {
pdoc->InsertString(pdoc->Length(), eol, strlen(eol));
GoToLine(currentLine + lineDelta);

selectionLength = pdoc->InsertString(CurrentPosition(), selectedText.Data(), selectionLength);
Sci::Position selectionLength = pdoc->InsertString(CurrentPosition(), selectedText.Data(), selectedText.Length());
if (appendEol) {
const Sci::Position lengthInserted = pdoc->InsertString(CurrentPosition() + selectionLength, eol, strlen(eol));
selectionLength += lengthInserted;
Expand Down

0 comments on commit d551765

Please sign in to comment.