summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-08-07 21:42:24 +0200
committerBram Moolenaar <Bram@vim.org>2019-08-07 21:42:24 +0200
commitb59e7357722d977830948572a395f0a175c7ded8 (patch)
tree4b67980c7e04c9986a51368b51b554cc61b9d546
parent5bcc5a1ff94bbab1b175e35a72e3df974106b393 (diff)
downloadvim-git-b59e7357722d977830948572a395f0a175c7ded8.tar.gz
patch 8.1.1825: allocating more memory than needed for extended structsv8.1.1825
Problem: Allocating more memory than needed for extended structs. Solution: Use offsetof() instead of sizeof(). (Dominique Pelle, closes #4785)
-rw-r--r--src/dict.c4
-rw-r--r--src/version.c2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/dict.c b/src/dict.c
index 45aa8246f..1097e58cd 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -210,7 +210,7 @@ dictitem_alloc(char_u *key)
{
dictitem_T *di;
- di = alloc(sizeof(dictitem_T) + STRLEN(key));
+ di = alloc(offsetof(dictitem_T, di_key) + STRLEN(key) + 1);
if (di != NULL)
{
STRCPY(di->di_key, key);
@@ -228,7 +228,7 @@ dictitem_copy(dictitem_T *org)
{
dictitem_T *di;
- di = alloc(sizeof(dictitem_T) + STRLEN(org->di_key));
+ di = alloc(offsetof(dictitem_T, di_key) + STRLEN(org->di_key) + 1);
if (di != NULL)
{
STRCPY(di->di_key, org->di_key);
diff --git a/src/version.c b/src/version.c
index 53c7a9d1b..3bb1cfd54 100644
--- a/src/version.c
+++ b/src/version.c
@@ -770,6 +770,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1825,
+/**/
1824,
/**/
1823,