diff options
Diffstat (limited to 'src/nvim/os/users.c')
-rw-r--r-- | src/nvim/os/users.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c index 8ebb7562ef..c6463c2c92 100644 --- a/src/nvim/os/users.c +++ b/src/nvim/os/users.c @@ -1,3 +1,6 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + // users.c -- operating system user information #include <uv.h> @@ -6,7 +9,6 @@ #include "nvim/os/os.h" #include "nvim/garray.h" #include "nvim/memory.h" -#include "nvim/misc2.h" #include "nvim/strings.h" #ifdef HAVE_PWD_H # include <pwd.h> @@ -73,11 +75,10 @@ int os_get_uname(uv_uid_t uid, char *s, size_t len) char *os_get_user_directory(const char *name) { #if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H) - struct passwd *pw; - if (name == NULL) { + if (name == NULL || *name == NUL) { return NULL; } - pw = getpwnam(name); // NOLINT(runtime/threadsafe_fn) + struct passwd *pw = getpwnam(name); // NOLINT(runtime/threadsafe_fn) if (pw != NULL) { // save the string from the static passwd entry into malloced memory return xstrdup(pw->pw_dir); |