aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/diff.c
diff options
context:
space:
mode:
authorAnatolii Sakhnik <sakhnik@gmail.com>2018-12-09 19:34:20 +0200
committerAnatolii Sakhnik <sakhnik@gmail.com>2018-12-09 19:45:56 +0200
commit271249a48a4847929410b9055bdb560e52271919 (patch)
tree2f9257be5b04eb58b0dccc5293798e7dbcd427fb /src/nvim/diff.c
parent2c92a4d0c8a398c8a7dfd1666fdcfd2ab89cc887 (diff)
downloadrneovim-271249a48a4847929410b9055bdb560e52271919.tar.gz
rneovim-271249a48a4847929410b9055bdb560e52271919.tar.bz2
rneovim-271249a48a4847929410b9055bdb560e52271919.zip
vim-patch:8.1.0400: using freed memory with :diffget
Problem: Using freed memory with :diffget. Solution: Skip ex_diffupdate() while updating diffs. (closes #3442) https://github.com/vim/vim/commit/d2b58c0a2c665075a8cfef57db6e1b37d4523e02
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r--src/nvim/diff.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 0fb8324546..9ac9b6f6db 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -42,7 +42,8 @@
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
-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
@@ -880,6 +881,11 @@ static int diff_internal_failed(void)
/// @param eap can be NULL
void ex_diffupdate(exarg_T *eap)
{
+ if (diff_busy) {
+ diff_need_update = true;
+ return;
+ }
+
// Delete all diffblocks.
diff_clear(curtab);
curtab->tp_diff_invalid = false;
@@ -2558,7 +2564,7 @@ void ex_diffgetput(exarg_T *eap)
change_warning(0);
if (diff_buf_idx(curbuf) != idx_to) {
EMSG(_("E787: Buffer changed unexpectedly"));
- return;
+ goto theend;
}
}
@@ -2723,7 +2729,12 @@ void 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.