vim-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.

a14e697547

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq 2025-02-03 11:11:46 +08:00
parent af069c5c05
commit 0309d3fbf0

View File

@ -2867,6 +2867,7 @@ void ex_function(exarg_T *eap)
if (tv_dict_add(fudi.fd_dict, fudi.fd_di) == FAIL) {
xfree(fudi.fd_di);
xfree(fp);
fp = NULL;
goto erret;
}
} else {
@ -2887,6 +2888,7 @@ void ex_function(exarg_T *eap)
hi->hi_key = UF2HIKEY(fp);
} else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) {
xfree(fp);
fp = NULL;
goto erret;
}
fp->uf_refcount = 1;