[geany/geany] d55176: scintilla: Fix invalid memory access in MoveSelectedLines

Colomban Wendling git-noreply at xxxxx
Sat Apr 27 14:12:50 UTC 2019


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sat, 27 Apr 2019 14:12:50 UTC
Commit:      d551765d59f0f92d5ffa68dba3f541f4c00c2c12
             https://github.com/geany/geany/commit/d551765d59f0f92d5ffa68dba3f541f4c00c2c12

Log Message:
-----------
scintilla: Fix invalid memory access in MoveSelectedLines

Fixes #2066.

X-Scintilla-Commit-ID: df5c32512d3d6b71ee6138c709b392258c3a1991,
                       25a0367e9349c8475c619a054af7bf1daf15b04c
X-Scintilla-Bug-ID: https://sourceforge.net/p/scintilla/bugs/2078/


Modified Paths:
--------------
    scintilla/src/Editor.cxx

Modified: scintilla/src/Editor.cxx
7 lines changed, 5 insertions(+), 2 deletions(-)
===================================================================
@@ -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);
@@ -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);
 
@@ -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;



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list