aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2018-04-10 01:01:16 +0300
committerZyX <kp-pav@yandex.ru>2018-04-10 01:51:52 +0300
commit07b67f9eff56ff741484109e4dcea42020c5f750 (patch)
treebb452785ba2c8b93ac1d138207d60ea020fe4f52
parent536d9a61687206318a629701aac984d55411bf35 (diff)
downloadrneovim-07b67f9eff56ff741484109e4dcea42020c5f750.tar.gz
rneovim-07b67f9eff56ff741484109e4dcea42020c5f750.tar.bz2
rneovim-07b67f9eff56ff741484109e4dcea42020c5f750.zip
eval: Fix PVS/V547: ufunc_T is actually an incomplete type
-rw-r--r--src/nvim/eval.c11
-rw-r--r--src/nvim/eval/typval.h5
2 files changed, 8 insertions, 8 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 9a5b508cb4..2fe89dba67 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -5807,8 +5807,8 @@ static int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate)
lambda_no++;
snprintf((char *)name, sizeof(name), "<lambda>%d", lambda_no);
- fp = (ufunc_T *)xcalloc(1, sizeof(ufunc_T) + STRLEN(name));
- pt = (partial_T *)xcalloc(1, sizeof(partial_T));
+ fp = xcalloc(1, offsetof(ufunc_T, uf_name) + STRLEN(name) + 1);
+ pt = xcalloc(1, sizeof(partial_T));
ga_init(&newlines, (int)sizeof(char_u *), 1);
ga_grow(&newlines, 1);
@@ -20059,7 +20059,7 @@ void ex_function(exarg_T *eap)
}
}
- fp = xcalloc(1, sizeof(ufunc_T) + STRLEN(name));
+ fp = xcalloc(1, offsetof(ufunc_T, uf_name) + STRLEN(name) + 1);
if (fudi.fd_dict != NULL) {
if (fudi.fd_di == NULL) {
@@ -20814,8 +20814,9 @@ char_u *get_user_func_name(expand_T *xp, int idx)
return (char_u *)""; // don't show dict and lambda functions
}
- if (STRLEN(fp->uf_name) + 4 >= IOSIZE)
- return fp->uf_name; /* prevents overflow */
+ if (STRLEN(fp->uf_name) + 4 >= IOSIZE) {
+ return fp->uf_name; // Prevent overflow.
+ }
cat_func_name(IObuff, fp);
if (xp->xp_context != EXPAND_USER_FUNC) {
diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h
index 2272a580d6..60bc7ff375 100644
--- a/src/nvim/eval/typval.h
+++ b/src/nvim/eval/typval.h
@@ -286,9 +286,8 @@ struct ufunc {
///< used for s: variables
int uf_refcount; ///< reference count, see func_name_refcount()
funccall_T *uf_scoped; ///< l: local variables for closure
- char_u uf_name[1]; ///< name of function (actually longer); can
- ///< start with <SNR>123_ (<SNR> is K_SPECIAL
- ///< KS_EXTRA KE_SNR)
+ char_u uf_name[]; ///< Name of function; can start with <SNR>123_
+ ///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR)
};
/// Maximum number of function arguments