diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-09-16 18:10:48 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-09-16 18:10:48 +0200 |
commit | d2b58c0a2c665075a8cfef57db6e1b37d4523e02 (patch) | |
tree | afabdf9dd96f05d7d4ac008929846d1f09f6721f /src/diff.c | |
parent | 65985ac998713dfe0f0ff1dd49c5e3e8f17f4870 (diff) | |
download | vim-git-d2b58c0a2c665075a8cfef57db6e1b37d4523e02.tar.gz |
patch 8.1.0400: using freed memory with :diffgetv8.1.0400
Problem: Using freed memory with :diffget.
Solution: Skip ex_diffupdate() while updating diffs. (closes #3442)
Diffstat (limited to 'src/diff.c')
-rw-r--r-- | src/diff.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/diff.c b/src/diff.c index 809694a68..d523e7743 100644 --- a/src/diff.c +++ b/src/diff.c @@ -21,7 +21,8 @@ #if defined(FEAT_DIFF) || defined(PROTO) -static int diff_busy = FALSE; /* ex_diffgetput() is busy */ +static int diff_busy = FALSE; // using diff structs, don't change them +static int diff_need_update = FALSE; // ex_diffupdate needs to be called /* flags obtained from the 'diffopt' option */ #define DIFF_FILLER 0x001 // display filler lines @@ -908,6 +909,12 @@ ex_diffupdate(exarg_T *eap) // "eap" can be NULL int idx_new; diffio_T diffio; + if (diff_busy) + { + diff_need_update = TRUE; + return; + } + // Delete all diffblocks. diff_clear(curtab); curtab->tp_diff_invalid = FALSE; @@ -2660,7 +2667,7 @@ ex_diffgetput(exarg_T *eap) if (diff_buf_idx(curbuf) != idx_to) { EMSG(_("E787: Buffer changed unexpectedly")); - return; + goto theend; } } @@ -2831,7 +2838,13 @@ ex_diffgetput(exarg_T *eap) aucmd_restbuf(&aco); } +theend: diff_busy = FALSE; + if (diff_need_update) + { + diff_need_update = FALSE; + ex_diffupdate(NULL); + } /* Check that the cursor is on a valid character and update it's position. * When there were filler lines the topline has become invalid. */ |