]> git.lyx.org Git - features.git/commitdiff
Fix another crash with Grid pasting (follow-up to #11906)
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 16 Aug 2020 15:23:16 +0000 (17:23 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 16 Aug 2020 15:24:13 +0000 (17:24 +0200)
src/mathed/InsetMathGrid.cpp

index 0a637ec715c26ae8f32d5bf4ab5f718de9d02385..26dd55f7f8e1c6a08cb147b238727ab4f69621c4 100644 (file)
@@ -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;