[LyX/master] Fix another crash with Grid pasting (follow-up to #11906)

Juergen Spitzmueller spitz at lyx.org
Sun Aug 16 14:58:55 UTC 2020


commit 957b615b1fd02ca8b5d7a44c26789c1bb90afd72
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sun Aug 16 17:23:16 2020 +0200

    Fix another crash with Grid pasting (follow-up to #11906)
---
 src/mathed/InsetMathGrid.cpp |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index 0a637ec..26dd55f 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -1634,8 +1634,10 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
 			for (row_type r = 0; r < numrows; ++r) {
 				for (col_type c = 0; c < numcols; ++c) {
 					idx_type i = index(r + startrow, c + startcol);
-					cell(i).insert(c == 0 ? cur.pos() : 0,
-					               grid.cell(grid.index(r, c)));
+					pos_type ipos = uint(cur.pos()) > cell(i).size()
+							? cell(i).size()
+							: cur.pos();
+					cell(i).insert(ipos, grid.cell(grid.index(r, c)));
 				}
 				if (hline_enabled)
 					rowinfo_[r].lines += grid.rowinfo_[r].lines;


More information about the lyx-cvs mailing list