# HG changeset patch # User Bram Moolenaar # Date 1565207106 -7200 # Node ID 8f82b1ec99b75fd2084c253c8ea1cedf8ca9a1f7 # Parent 8c3b0893d1fec338297289a2b94380df587601fe patch 8.1.1825: allocating more memory than needed for extended structs commit https://github.com/vim/vim/commit/b59e7357722d977830948572a395f0a175c7ded8 Author: Bram Moolenaar Date: Wed Aug 7 21:42:24 2019 +0200 patch 8.1.1825: allocating more memory than needed for extended structs Problem: Allocating more memory than needed for extended structs. Solution: Use offsetof() instead of sizeof(). (Dominique Pelle, closes #4785) diff --git a/src/dict.c b/src/dict.c --- 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 --- 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,