]> granicus.if.org Git - vim/commitdiff
patch 8.1.1675: listener list not correctly updated on listener_remove() v8.1.1675
authorBram Moolenaar <Bram@vim.org>
Sat, 13 Jul 2019 11:03:02 +0000 (13:03 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 13 Jul 2019 11:03:02 +0000 (13:03 +0200)
Problem:    Listener list not correctly updated on listener_remove().
Solution:   Only set "prev" when not removing a listener.  Return one if the
            listener was found and removed.

src/change.c
src/version.c

index b928786eb03322a3fae8507a671d72ff6a4ba24f..761e764f8556724461be91f8624cce8d732c3aa3 100644 (file)
@@ -325,15 +325,17 @@ f_listener_flush(typval_T *argvars, typval_T *rettv UNUSED)
  * listener_remove() function
  */
     void
-f_listener_remove(typval_T *argvars, typval_T *rettv UNUSED)
+f_listener_remove(typval_T *argvars, typval_T *rettv)
 {
     listener_T *lnr;
     listener_T *next;
-    listener_T *prev = NULL;
+    listener_T *prev;
     int                id = tv_get_number(argvars);
     buf_T      *buf;
 
     for (buf = firstbuf; buf != NULL; buf = buf->b_next)
+    {
+       prev = NULL;
        for (lnr = buf->b_listener; lnr != NULL; lnr = next)
        {
            next = lnr->lr_next;
@@ -345,9 +347,12 @@ f_listener_remove(typval_T *argvars, typval_T *rettv UNUSED)
                    buf->b_listener = lnr->lr_next;
                free_callback(&lnr->lr_callback);
                vim_free(lnr);
+               rettv->vval.v_number = 1;
+               return;
            }
            prev = lnr;
        }
+    }
 }
 
 /*
index 04a2e6826d88814e380b8cd32d6761bde476a972..7e3c18059252931d04260d94e4b4e2c624d3d365 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1675,
 /**/
     1674,
 /**/