patch 9.0.1391: "clear" macros are not always used
Problem: "clear" macros are not always used.
Solution: Use ALLOC_ONE, VIM_CLEAR, CLEAR_POINTER and CLEAR_FIELD in more
places. (Yegappan Lakshmanan, closes #12104)
diff --git a/src/userfunc.c b/src/userfunc.c
index 878e07f..3885f67 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -5155,15 +5155,13 @@
fudi.fd_di = dictitem_alloc(fudi.fd_newkey);
if (fudi.fd_di == NULL)
{
- vim_free(fp);
- fp = NULL;
+ VIM_CLEAR(fp);
goto erret;
}
if (dict_add(fudi.fd_dict, fudi.fd_di) == FAIL)
{
vim_free(fudi.fd_di);
- vim_free(fp);
- fp = NULL;
+ VIM_CLEAR(fp);
goto erret;
}
}
@@ -5292,10 +5290,7 @@
clear_type_list(&fp->uf_type_list);
}
if (free_fp)
- {
- vim_free(fp);
- fp = NULL;
- }
+ VIM_CLEAR(fp);
ret_free:
ga_clear_strings(&argtypes);
vim_free(fudi.fd_newkey);