0
0
mirror of https://github.com/vim/vim.git synced 2025-11-15 23:14:06 -05:00

patch 9.1.1792: List of changes not protected from changes

Problem:  List of changes not protected from changes when processing
          listeners (after v9.1.1782)
Solution: Fully lock changes list for listener callbacks (Paul Ollis)

closes: #18385

Signed-off-by: Paul Ollis <paul@cleversheep.org>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Paul Ollis
2025-09-25 20:11:34 +00:00
committed by Christian Brabandt
parent 377339dff3
commit 35a89ce9db
3 changed files with 24 additions and 3 deletions

View File

@@ -297,7 +297,6 @@ may_record_change(
if (curbuf->b_recorded_changes == NULL) // out of memory
return;
++curbuf->b_recorded_changes->lv_refcount;
curbuf->b_recorded_changes->lv_lock = VAR_FIXED;
}
dict = dict_alloc();
@@ -489,6 +488,7 @@ invoke_listener_set(
listener_T *lnr;
typval_T rettv;
typval_T argv[6];
typval_T val;
argv[0].v_type = VAR_NUMBER;
argv[0].vval.v_number = buf->b_fnum; // a:bufnr
@@ -501,6 +501,13 @@ invoke_listener_set(
argv[4].v_type = VAR_LIST;
argv[4].vval.v_list = recorded_changes;
// Ensure the list of changes is locked to prevent any modifications by
// callback code..
val.v_type = VAR_LIST;
val.v_lock = 0;
val.vval.v_list = recorded_changes;
item_lock(&val, -1, TRUE, FALSE);
// Protect against recursive callbacks, lock the buffer against changes and
// set the updating_screen flag to prevent channel input processing, which
// might also try to update the buffer.
@@ -547,7 +554,6 @@ invoke_sync_listeners(
return;
++recorded_changes->lv_refcount;
recorded_changes->lv_lock = VAR_FIXED;
dict = dict_alloc();
if (dict == NULL)