From 39963c6a04afc417a821b2255a5caea4b7955d7d Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 4 Dec 2019 08:01:05 -0500 Subject: os_getenvname_at_index: Handle Windows env vars whose name starts with = --- src/nvim/os/env.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index ac442ee2e8..360609c50d 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -302,7 +302,10 @@ char *os_getenvname_at_index(size_t index) break; } - const char * const end = strchr(utf8_str, '='); + // Some Windows env vars start with =, so skip over that to find the + // separator between name/value + const char * const end = strchr(utf8_str + (utf8_str[0] == '=' ? 1 : 0), + '='); assert(end != NULL); ptrdiff_t len = end - utf8_str; assert(len > 0); -- cgit