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)
diff --git a/src/change.c b/src/change.c
index 6b402f1..0eb00c2 100644
--- a/src/change.c
+++ b/src/change.c
@@ -300,7 +300,7 @@
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 @@
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
/*