mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 17:36:29 +00:00
pvs/V575: false positive (#7462)
./src/nvim/ex_getln.c:2787:1: error: V575 The 'memcpy' function doesn't copy the whole string. Use 'strcpy / strcpy_s' function to preserve terminal null. We could instead "trick" PVS like this: diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e79476ab532a..295630693b27 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2782,9 +2782,10 @@ static void ui_ext_cmdline_show(CmdlineInfo *line) void ui_ext_cmdline_block_append(int indent, const char *line) { - char *buf = xmallocz(indent + strlen(line)); + size_t linelen = strlen(line); + char *buf = xmallocz(indent + linelen); memset(buf, ' ', indent); - memcpy(buf+indent, line, strlen(line)); + memcpy(buf + indent, line, linelen); Array item = ARRAY_DICT_INIT; ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT));
This commit is contained in:
@@ -2784,7 +2784,7 @@ void ui_ext_cmdline_block_append(int indent, const char *line)
|
|||||||
{
|
{
|
||||||
char *buf = xmallocz(indent + strlen(line));
|
char *buf = xmallocz(indent + strlen(line));
|
||||||
memset(buf, ' ', indent);
|
memset(buf, ' ', indent);
|
||||||
memcpy(buf+indent, line, strlen(line));
|
memcpy(buf + indent, line, strlen(line)); // -V575
|
||||||
|
|
||||||
Array item = ARRAY_DICT_INIT;
|
Array item = ARRAY_DICT_INIT;
|
||||||
ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT));
|
ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT));
|
||||||
|
Reference in New Issue
Block a user