# HG changeset patch # User Bram Moolenaar # Date 1590442203 -7200 # Node ID dd3165956464483d673cc13c927eb89b6b38cba3 # Parent fa41a7fbaf5ce6f6caef47a1cac1d0b492096d47 patch 8.2.0825: def_function() may return pointer that was freed Commit: https://github.com/vim/vim/commit/a14e6975478adeddcc2161edc1ec611016aa89f3 Author: Bram Moolenaar Date: Mon May 25 23:29:28 2020 +0200 patch 8.2.0825: def_function() may return pointer that was freed Problem: def_function() may return pointer that was freed. Solution: Set "fp" to NULL after freeing it. diff --git a/src/userfunc.c b/src/userfunc.c --- a/src/userfunc.c +++ b/src/userfunc.c @@ -3140,12 +3140,14 @@ def_function(exarg_T *eap, char_u *name_ if (fudi.fd_di == NULL) { vim_free(fp); + fp = NULL; goto erret; } if (dict_add(fudi.fd_dict, fudi.fd_di) == FAIL) { vim_free(fudi.fd_di); vim_free(fp); + fp = NULL; goto erret; } } @@ -3169,6 +3171,7 @@ def_function(exarg_T *eap, char_u *name_ else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) { vim_free(fp); + fp = NULL; goto erret; } fp->uf_refcount = 1; diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 825, +/**/ 824, /**/ 823,