From d19e7a4b38c84c267a79dc8ce270b61863b119ac Mon Sep 17 00:00:00 2001 From: Alexey Date: Mon, 19 Oct 2020 16:46:17 +0300 Subject: [PATCH] fixing crash in https://github.com/Alexey-T/CudaText/issues/2924 --- atsynedit/atsynedit_carets.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/atsynedit/atsynedit_carets.inc b/atsynedit/atsynedit_carets.inc index cd398260b..3863ab334 100644 --- a/atsynedit/atsynedit_carets.inc +++ b/atsynedit/atsynedit_carets.inc @@ -178,6 +178,7 @@ var begin Result.X:= -1; Result.Y:= -1; + if not AStrings.IsIndexValid(P.Y) then Exit; AWrapInfo.FindIndexesOfLineNumber(P.Y, NIndex1, NIndex2); if NIndex1<0 then Exit; @@ -349,6 +350,8 @@ begin Item:= AWrapInfo[NIndex]; Result.Y:= Item.NLineIndex; Result.X:= Item.NCharIndex+Item.NLength-1; + if not AStrings.IsIndexValid(Result.Y) then + exit(Point(-1, -1)); end; Exit end; @@ -357,6 +360,8 @@ begin //click in text Item:= AWrapInfo[NIndex]; Result.Y:= Item.NLineIndex; + if not AStrings.IsIndexValid(Result.Y) then + exit(Point(-1, -1)); Str:= AStrings.LineSub( Result.Y,