diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-10-01 17:02:16 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-10-01 17:02:16 +0200 |
commit | 8617348e2110c2c8387ea448a6258f1effa8d249 (patch) | |
tree | fab9e6b710dba337eb5439160f84e2fead1103cf /src/change.c | |
parent | b4367b7fb65f6a88f76ef99f79342341af0b1017 (diff) | |
download | vim-git-8617348e2110c2c8387ea448a6258f1effa8d249.tar.gz |
patch 8.1.2107: various memory leaks reported by asanv8.1.2107
Problem: Various memory leaks reported by asan.
Solution: Free the memory. (Ozaki Kiichi, closes #5003)
Diffstat (limited to 'src/change.c')
-rw-r--r-- | src/change.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/change.c b/src/change.c index 6b402f189..0eb00c283 100644 --- a/src/change.c +++ b/src/change.c @@ -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 /* |