diff options
Diffstat (limited to 'src/nvim/os/env.c')
-rw-r--r-- | src/nvim/os/env.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index eb86cb8ac7..15153e9bd7 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -184,7 +184,7 @@ int os_unsetenv(const char *name) return r == 0 ? 0 : -1; } -char *os_getenvname_at_index(size_t index) +char **os_getfullenv(void) { #ifdef _WIN32 wchar_t *env = GetEnvironmentStringsW(); @@ -224,13 +224,20 @@ char *os_getenvname_at_index(size_t index) # else extern char **environ; # endif - // Check if index is inside the environ array and is not the last element. + return environ; +} + +char *os_getenvname_at_index(size_t index) +{ + char **env = os_getfullenv(); + // check if index is inside the environ array for (size_t i = 0; i <= index; i++) { - if (environ[i] == NULL) { + if (env[i] == NULL) { return NULL; } } - char *str = environ[index]; + char *str = env[index]; + assert(str != NULL); size_t namesize = 0; while (str[namesize] != '=' && str[namesize] != NUL) { namesize++; |