File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -297,7 +297,6 @@ may_record_change(
297
297
if (curbuf -> b_recorded_changes == NULL ) // out of memory
298
298
return ;
299
299
++ curbuf -> b_recorded_changes -> lv_refcount ;
300
- curbuf -> b_recorded_changes -> lv_lock = VAR_FIXED ;
301
300
}
302
301
303
302
dict = dict_alloc ();
@@ -489,6 +488,7 @@ invoke_listener_set(
489
488
listener_T * lnr ;
490
489
typval_T rettv ;
491
490
typval_T argv [6 ];
491
+ typval_T val ;
492
492
493
493
argv [0 ].v_type = VAR_NUMBER ;
494
494
argv [0 ].vval .v_number = buf -> b_fnum ; // a:bufnr
@@ -501,6 +501,13 @@ invoke_listener_set(
501
501
argv [4 ].v_type = VAR_LIST ;
502
502
argv [4 ].vval .v_list = recorded_changes ;
503
503
504
+ // Ensure the list of changes is locked to prevent any modifications by
505
+ // callback code..
506
+ val .v_type = VAR_LIST ;
507
+ val .v_lock = 0 ;
508
+ val .vval .v_list = recorded_changes ;
509
+ item_lock (& val , -1 , TRUE, FALSE);
510
+
504
511
// Protect against recursive callbacks, lock the buffer against changes and
505
512
// set the updating_screen flag to prevent channel input processing, which
506
513
// might also try to update the buffer.
@@ -547,7 +554,6 @@ invoke_sync_listeners(
547
554
return ;
548
555
549
556
++ recorded_changes -> lv_refcount ;
550
- recorded_changes -> lv_lock = VAR_FIXED ;
551
557
552
558
dict = dict_alloc ();
553
559
if (dict == NULL )
Original file line number Diff line number Diff line change @@ -21,8 +21,21 @@ func s:AnotherStoreList(l)
21
21
endfunc
22
22
23
23
func s: EvilStoreList (l )
24
+ func ! Modify_dict_in_list (the_list, key )
25
+ let a: the_list [0 ][a: key ] = a: the_list [0 ][a: key ] + 1
26
+ endfunc
27
+ func ! Modify_list_entry (the_list)
28
+ let a: the_list [0 ] = 42
29
+ endfunc
30
+
24
31
let s: list3 = a: l
25
- call assert_fails (" call add(a:l, 'myitem')" , " E742:" )
32
+ call assert_fails (" call add(a:l, 'myitem')" , " E741:" )
33
+ call assert_fails (" call remove(a:l, 1)" , " E741:" )
34
+ call assert_fails (" call Modify_dict_in_list(a:l, 'lnum')" , " E741:" )
35
+ call assert_fails (" call Modify_dict_in_list(a:l, 'end')" , " E741:" )
36
+ call assert_fails (" call Modify_dict_in_list(a:l, 'col')" , " E741:" )
37
+ call assert_fails (" call Modify_dict_in_list(a:l, 'added')" , " E741:" )
38
+ call assert_fails (" call Modify_list_entry(a:l)" , " E741:" )
26
39
endfunc
27
40
28
41
func Test_listening ()
Original file line number Diff line number Diff line change @@ -729,6 +729,8 @@ static char *(features[]) =
729
729
730
730
static int included_patches [] =
731
731
{ /* Add new patch number below this line */
732
+ /**/
733
+ 1792 ,
732
734
/**/
733
735
1791 ,
734
736
/**/
You can’t perform that action at this time.
0 commit comments