mirror of
https://github.com/neovim/neovim.git
synced 2025-09-24 20:18:32 +00:00
xstrlcat: Allow overlapped pointers. (#6017)
memcpy is not equivalent to memmove (which is used by vim_strcat), this could cause subtle bugs if xstrlcat is used as a replacement for vim_strcat. But vim_strcat is inconsistent: in the `else` branch it uses strcpy, which doesn't allow overlap. Helped-by: oni-link <knil.ino@gmail.com> Helped-by: James McCoy <jamessan@jamessan.com> Helped-by: Nikolai Aleksandrovich Pavlov <kp-pav@yandex.ru>
This commit is contained in:
@@ -129,9 +129,10 @@ newwindow:
|
||||
vim_snprintf(cbuf, sizeof(cbuf) - 5, "%" PRId64, (int64_t)Prenum);
|
||||
else
|
||||
cbuf[0] = NUL;
|
||||
if (nchar == 'v' || nchar == Ctrl_V)
|
||||
strcat(cbuf, "v");
|
||||
strcat(cbuf, "new");
|
||||
if (nchar == 'v' || nchar == Ctrl_V) {
|
||||
xstrlcat(cbuf, "v", sizeof(cbuf));
|
||||
}
|
||||
xstrlcat(cbuf, "new", sizeof(cbuf));
|
||||
do_cmdline_cmd(cbuf);
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user