summaryrefslogtreecommitdiffstats
path: root/src/diff.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-06-26 16:53:34 +0100
committerBram Moolenaar <Bram@vim.org>2022-06-26 16:53:34 +0100
commitc101abff4c6756db4f5e740fde289decb9452efa (patch)
tree26385200c1dd4f3cc47f708d63a897514bc8795e /src/diff.c
parentcd38bb4d83c942c4bad596835c6766cbf32e5195 (diff)
patch 8.2.5164: invalid memory access after diff buffer manipulationsv8.2.5164
Problem: Invalid memory access after diff buffer manipulations. Solution: Use zero offset when change removes all lines in a diff block.
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/diff.c b/src/diff.c
index eddf331656..91e5ae2f2f 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -403,9 +403,9 @@ diff_mark_adjust_tp(
// 2. 3. 4. 5.: inserted/deleted lines touching this diff.
if (deleted > 0)
{
+ off = 0;
if (dp->df_lnum[idx] >= line1)
{
- off = dp->df_lnum[idx] - lnum_deleted;
if (last <= line2)
{
// 4. delete all lines of diff
@@ -426,6 +426,7 @@ diff_mark_adjust_tp(
else
{
// 5. delete lines at or just before top of diff
+ off = dp->df_lnum[idx] - lnum_deleted;
n = off;
dp->df_count[idx] -= line2 - dp->df_lnum[idx] + 1;
check_unchanged = TRUE;
@@ -434,7 +435,6 @@ diff_mark_adjust_tp(
}
else
{
- off = 0;
if (last < line2)
{
// 2. delete at end of diff