# HG changeset patch # User Christian Brabandt # Date 1537114504 -7200 # Node ID 09c1f241e2f7ad378c62a437b8617b2050cfd4f4 # Parent 33e99ee96b06ff2ce56e9c4fe487e90c860b3686 patch 8.1.0400: using freed memory with :diffget commit https://github.com/vim/vim/commit/d2b58c0a2c665075a8cfef57db6e1b37d4523e02 Author: Bram Moolenaar Date: Sun Sep 16 18:10:48 2018 +0200 patch 8.1.0400: using freed memory with :diffget Problem: Using freed memory with :diffget. Solution: Skip ex_diffupdate() while updating diffs. (closes https://github.com/vim/vim/issues/3442) diff --git a/src/diff.c b/src/diff.c --- 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 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. */ diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -795,6 +795,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 400, +/**/ 399, /**/ 398,