diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-22 20:29:09 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-22 20:29:09 +0000 |
commit | b4168fd917e869912e0649fe13c10e5e6a595199 (patch) | |
tree | 6f0cfb21ffa19c605c3499faa62a01519f3e49e1 /src/dict.c | |
parent | a80aad717464760a5a50ac2201ce35b24a0cf7a5 (diff) |
patch 8.2.3875: gcc complains about buffer overrunv8.2.3875
Problem: gcc complains about buffer overrun.
Solution: Use mch_memmove() instead of STRCPY(). (John Marriott)
Diffstat (limited to 'src/dict.c')
-rw-r--r-- | src/dict.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/dict.c b/src/dict.c index f2989fff21..b49005ab4f 100644 --- a/src/dict.c +++ b/src/dict.c @@ -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; |