summaryrefslogtreecommitdiffstats
path: root/src/diff.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-07-28 18:44:27 +0100
committerBram Moolenaar <Bram@vim.org>2022-07-28 18:44:27 +0100
commit4e677b9c40ccbc5f090971b31dc2fe07bf05541d (patch)
tree80c6f0dd96f2d82b5ebb9fe0b2e36d1fc5a6c1af /src/diff.c
parentcb5ed4d6252a7c76c2f85ae95cb1e4e2bccc41fc (diff)
patch 9.0.0101: invalid memory access in diff mode with "dp" and undov9.0.0101
Problem: Invalid memory access in diff mode with "dp" and undo. Solution: Make sure the line number does not go below one.
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/diff.c b/src/diff.c
index e4bafe2c93..fb43eee844 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -464,7 +464,10 @@ diff_mark_adjust_tp(
for (i = 0; i < DB_COUNT; ++i)
if (tp->tp_diffbuf[i] != NULL && i != idx)
{
- dp->df_lnum[i] -= off;
+ if (dp->df_lnum[i] > off)
+ dp->df_lnum[i] -= off;
+ else
+ dp->df_lnum[i] = 1;
dp->df_count[i] += n;
}
}
@@ -2863,8 +2866,8 @@ ex_diffgetput(exarg_T *eap)
{
// remember deleting the last line of the buffer
buf_empty = curbuf->b_ml.ml_line_count == 1;
- ml_delete(lnum);
- --added;
+ if (ml_delete(lnum) == OK)
+ --added;
}
for (i = 0; i < dp->df_count[idx_from] - start_skip - end_skip; ++i)
{