os_getenvname_at_index: Handle Windows env vars whose name starts with =

This commit is contained in:
James McCoy 2019-12-04 08:01:05 -05:00
parent 6dc1005787
commit 39963c6a04
No known key found for this signature in database
GPG Key ID: DFE691AE331BA3DB

View File

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