summaryrefslogtreecommitdiffstats
path: root/src/getchar.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/getchar.c
parent8c5a278fc508da6dfe50e69b6ee734451aa4eafb (diff)
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/getchar.c')
-rw-r--r--src/getchar.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/getchar.c b/src/getchar.c
index 4a3587c3f2..b0e72f58f2 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -232,7 +232,7 @@ add_buff(
len = MINIMAL_SIZE;
else
len = slen;
- p = alloc(sizeof(buffblock_T) + len);
+ p = alloc(offsetof(buffblock_T, b_str) + len + 1);
if (p == NULL)
return; /* no space, just forget it */
buf->bh_space = (int)(len - slen);