From d15defeb2f3b964510e0e6013a7efef7613ad26d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 24 Sep 2021 01:50:07 -0700 Subject: fix(PVS V507): false positive https://pvs-studio.com/en/docs/warnings/v507/ "Pointer to local array 'sourcing_name_buf' is stored outside the scope of this array. Such a pointer will become invalid." False positive: `sourcing_name = save_sourcing_name` before returning from this scope. --- src/nvim/ex_cmds2.c | 2 +- src/nvim/memory.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index d8827f0a3d..1a576bd891 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1950,7 +1950,7 @@ static int source_using_linegetter(void *cookie, LineGetter fgetline, const char snprintf((char *)sourcing_name_buf, sizeof(sourcing_name_buf), "%s called at %s:%" PRIdLINENR, traceback_name, save_sourcing_name, save_sourcing_lnum); - sourcing_name = sourcing_name_buf; + sourcing_name = sourcing_name_buf; // -V507 reassigned below, before return. } sourcing_lnum = 0; diff --git a/src/nvim/memory.c b/src/nvim/memory.c index cc9c047fa0..0f5f4c1e40 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -170,6 +170,8 @@ void *xrealloc(void *ptr, size_t size) /// xmalloc() wrapper that allocates size + 1 bytes and zeroes the last byte /// +/// Commonly used to allocate strings, e.g. `char *s = xmallocz(len)`. +/// /// @see {xmalloc} /// @param size /// @return pointer to allocated space. Never NULL -- cgit