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.
This commit is contained in:
Justin M. Keyes 2021-09-24 01:50:07 -07:00
parent 433bda405e
commit d15defeb2f
2 changed files with 3 additions and 1 deletions

View File

@ -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;

View File

@ -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