Problem: Various memory leaks reported by asan.
Solution: Free the memory. (Ozaki Kiichi, closes #5003)
/* b:changedtick uses an item in buf_T, remove it now */
dictitem_remove(buf->b_vars, (dictitem_T *)&buf->b_ct_di);
unref_var_dict(buf->b_vars);
+ remove_listeners(buf);
#endif
#ifdef FEAT_LUA
lua_buffer_free(buf);
#ifdef FEAT_JOB_CHANNEL
vim_free(buf->b_prompt_text);
free_callback(&buf->b_prompt_callback);
+ free_callback(&buf->b_prompt_interrupt);
#endif
buf_hashtab_remove(buf);
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)
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
/*
semsg(_(e_missingparen), "lambda");
}
clear_tv(rettv);
- return FAIL;
+ ret = FAIL;
}
- return call_func_rettv(arg, rettv, evaluate, NULL, &base);
+ else
+ ret = call_func_rettv(arg, rettv, evaluate, NULL, &base);
+
+ // Clear the funcref afterwards, so that deleting it while
+ // evaluating the arguments is possible (see test55).
+ if (evaluate)
+ clear_tv(&base);
+
+ return ret;
}
/*
{
if (rettv_list_alloc(rettv) != FAIL && result != NULL)
list_append_string(rettv->vval.v_list, result, -1);
- else
- vim_free(result);
+ vim_free(result);
}
else
rettv->vval.v_string = result;
&& (do_buffer || (p->indir & PV_BUF) == 0)
&& !(options[i].flags & P_NODEFAULT)
&& !optval_default(p, varp, FALSE))
- set_option_default(i, OPT_LOCAL, FALSE);
+ set_option_default(i, OPT_FREE|OPT_LOCAL, FALSE);
}
unblock_autocmds();
trunc_string(wp->w_popup_title, title, total_width - 2, len);
screen_puts(title, wp->w_winrow, wp->w_wincol + 1,
wp->w_popup_border[0] > 0 ? border_attr[0] : popup_attr);
+ vim_free(title);
}
// Compute scrollbar thumb position and size.
void f_listener_remove(typval_T *argvars, typval_T *rettv);
void may_invoke_listeners(buf_T *buf, linenr_T lnum, linenr_T lnume, int added);
void invoke_listeners(buf_T *buf);
+void remove_listeners(buf_T *buf);
void changed_bytes(linenr_T lnum, colnr_T col);
void appended_lines(linenr_T lnum, long count);
void appended_lines_mark(linenr_T lnum, long count);
int i;
for (i = script_items.ga_len; i > 0; --i)
+ {
vim_free(SCRIPT_ITEM(i).sn_name);
+ ga_clear(&SCRIPT_ITEM(i).sn_prl_ga);
+ }
ga_clear(&script_items);
}
}
ga_clear(&ga_text);
+ ga_clear(&ga_cell);
vim_free(prev_char);
return max_cells;
buf = curbuf;
while (!(curbuf->b_ml.ml_flags & ML_EMPTY))
ml_delete((linenr_T)1, FALSE);
- ga_clear(&curbuf->b_term->tl_scrollback);
+ free_scrollback(curbuf->b_term);
redraw_later(NOT_VALID);
}
}
" todo: lambda accepts more arguments than it consumes
" call assert_fails('eval "text"->{x -> x .. " extended"}("more")', 'E99:')
+
+ let l = [1, 2, 3]
+ eval l->{x -> x}()
+ call assert_equal(1, test_refcount(l))
endfunc
func Test_method_not_supported()
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2107,
/**/
2106,
/**/