1
0
forked from aniani/vim

patch 9.0.0361: removing a listener may result in a memory leak

Problem:    Removing a listener may result in a memory leak and remove
            subsequent listerns.
Solution:   Init the "prev" pointer only once. (Yegappan Lakshmanan,
            closes #11039)
This commit is contained in:
Yegappan Lakshmanan
2022-09-02 17:12:07 +01:00
committed by Bram Moolenaar
parent 35d21c6830
commit 956be4678f
3 changed files with 35 additions and 2 deletions

View File

@@ -362,6 +362,7 @@ invoke_listeners(buf_T *buf)
int save_updating_screen = updating_screen;
static int recursive = FALSE;
listener_T *next;
listener_T *prev;
if (buf->b_recorded_changes == NULL // nothing changed
|| buf->b_listener == NULL // no listeners
@@ -406,10 +407,9 @@ invoke_listeners(buf_T *buf)
}
// If f_listener_remove() was called may have to remove a listener now.
prev = NULL;
for (lnr = buf->b_listener; lnr != NULL; lnr = next)
{
listener_T *prev = NULL;
next = lnr->lr_next;
if (lnr->lr_id == 0)
remove_listener(buf, lnr, prev);