1
0
forked from aniani/vim

patch 8.1.2107: various memory leaks reported by asan

Problem:    Various memory leaks reported by asan.
Solution:   Free the memory. (Ozaki Kiichi, closes #5003)
This commit is contained in:
Bram Moolenaar
2019-10-01 17:02:16 +02:00
parent b4367b7fb6
commit 8617348e21
11 changed files with 46 additions and 7 deletions

View File

@@ -300,7 +300,7 @@ f_listener_remove(typval_T *argvars, typval_T *rettv)
int id = tv_get_number(argvars);
buf_T *buf;
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
FOR_ALL_BUFFERS(buf)
{
prev = NULL;
for (lnr = buf->b_listener; lnr != NULL; lnr = next)
@@ -402,6 +402,24 @@ invoke_listeners(buf_T *buf)
after_updating_screen(TRUE);
recursive = FALSE;
}
/*
* Remove all listeners associated with "buf".
*/
void
remove_listeners(buf_T *buf)
{
listener_T *lnr;
listener_T *next;
for (lnr = buf->b_listener; lnr != NULL; lnr = next)
{
next = lnr->lr_next;
free_callback(&lnr->lr_callback);
vim_free(lnr);
}
buf->b_listener = NULL;
}
#endif
/*