Skip to content

Commit

Permalink
patch 8.2.3875: gcc complains about buffer overrun
Browse files Browse the repository at this point in the history
Problem:    gcc complains about buffer overrun.
Solution:   Use mch_memmove() instead of STRCPY(). (John Marriott)
  • Loading branch information
brammool committed Dec 22, 2021
1 parent a80aad7 commit b4168fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,12 @@ dict_free_items(int copyID)
dictitem_alloc(char_u *key)
{
dictitem_T *di;
size_t len = STRLEN(key);

di = alloc(offsetof(dictitem_T, di_key) + STRLEN(key) + 1);
di = alloc(offsetof(dictitem_T, di_key) + len + 1);
if (di != NULL)
{
STRCPY(di->di_key, key);
mch_memmove(di->di_key, key, len + 1);
di->di_flags = DI_FLAGS_ALLOC;
di->di_tv.v_lock = 0;
di->di_tv.v_type = VAR_UNKNOWN;
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3875,
/**/
3874,
/**/
Expand Down

0 comments on commit b4168fd

Please sign in to comment.