summaryrefslogtreecommitdiff
path: root/src/syntax.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-08-08 20:49:14 +0200
committerBram Moolenaar <Bram@vim.org>2019-08-08 20:49:14 +0200
commit47ed553fd5bebfc36eb8aa81686eeaa5a84eccac (patch)
tree73dbe93fe15754af8a4384ef66d7f595c9bbb8a6 /src/syntax.c
parent8c5a278fc508da6dfe50e69b6ee734451aa4eafb (diff)
downloadvim-git-47ed553fd5bebfc36eb8aa81686eeaa5a84eccac.tar.gz
patch 8.1.1827: allocating more memory than needed for extended structsv8.1.1827
Problem: Allocating more memory than needed for extended structs. Solution: Use offsetof() instead of sizeof(). (Dominique Pelle, closes #4786)
Diffstat (limited to 'src/syntax.c')
-rw-r--r--src/syntax.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/syntax.c b/src/syntax.c
index ad2e1a0cc..3d06f44f7 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -4394,7 +4394,7 @@ add_keyword(
name_folded, MAXKEYWLEN + 1);
else
name_ic = name;
- kp = alloc(sizeof(keyentry_T) + STRLEN(name_ic));
+ kp = alloc(offsetof(keyentry_T, keyword) + STRLEN(name_ic) + 1);
if (kp == NULL)
return;
STRCPY(kp->keyword, name_ic);