Skip to content

Commit

Permalink
fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
prabirshrestha committed Jun 17, 2020
1 parent 9894283 commit d2774ff
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
2 changes: 1 addition & 1 deletion src/if_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -2459,7 +2459,7 @@ luaV_call_lua_func_free(void *state)
luaV_CFuncState *funcstate = (luaV_CFuncState*)state;
luaL_unref(L, LUA_REGISTRYINDEX, funcstate->index);
funcstate->L = NULL;
VIM_CLEAR(state);
VIM_CLEAR(funcstate);
}

#endif
8 changes: 0 additions & 8 deletions src/userfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ register_cfunc(cfunc_T cb, cfunc_free_T cb_free, void *state)
{
char_u *name = get_lambda_name();
ufunc_T *fp = NULL;
partial_T *pt = NULL;
int flags = FC_CFUNC;
garray_T newargs;
garray_T newlines;
Expand All @@ -357,9 +356,6 @@ register_cfunc(cfunc_T cb, cfunc_free_T cb_free, void *state)
fp = alloc_clear(offsetof(ufunc_T, uf_name) + STRLEN(name) + 1);
if (fp == NULL)
goto errret;
pt = ALLOC_CLEAR_ONE(partial_T);
if (pt == NULL)
goto errret;

fp->uf_dfunc_idx = UF_NOT_COMPILED;
fp->uf_refcount = 1;
Expand All @@ -376,16 +372,12 @@ register_cfunc(cfunc_T cb, cfunc_free_T cb_free, void *state)
set_ufunc_name(fp, name);
hash_add(&func_hashtab, UF2HIKEY(fp));

pt->pt_func = fp;
pt->pt_refcount = 1;

return name;

errret:
ga_clear_strings(&newargs);
ga_clear_strings(&newlines);
vim_free(fp);
vim_free(pt);
return NULL;
}

Expand Down

0 comments on commit d2774ff

Please sign in to comment.