On 23-Dec-2021 06:19, Bram Moolenaar wrote:
John Marriott wrote:
On 23-Dec-2021 05:20, Bram Moolenaar wrote:
Patch 8.2.3871
Problem: List.c contains code for dict and blob.
Solution: Refactor to put code where it belongs. (Yegappan Lakshmanan,
closes #9386)
Files: src/blob.c, src/dict.c, src/list.c, src/proto/blob.pro,
src/proto/dict.pro, src/proto/list.pro, src/proto/strings.pro,
src/strings.c, src/structs.h, src/testdir/test_filter_map.vim,
src/testdir/test_listdict.vim, src/testdir/test_sort.vim
Is that because of the "actually longer" thing?
Yeah I think so.
Any idea how to avoid the error?
The attached patch changes dictitem_alloc() to use the same mechanism as
dictitem_copy() just below it.
What do you think?
Cheers
John
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/f9082c33-d8c1-3ba8-91ac-3a32b80045e7%40internode.on.net.
--- dict.c.orig 2021-12-23 05:28:28.586848100 +1100
+++ dict.c 2021-12-23 07:12:53.587225300 +1100
@@ -222,11 +222,12 @@
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;