Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: fix empty-named env var assertion failure #32921

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/node_env_var.cc
Expand Up @@ -121,7 +121,7 @@ void RealEnvStore::Set(Isolate* isolate,
node::Utf8Value val(isolate, value);

#ifdef _WIN32
if (key[0] == L'=') return;
if (key.length() > 0 && key[0] == '=') return;
#endif
uv_os_setenv(*key, *val);
DateTimeConfigurationChangeNotification(isolate, key);
Expand All @@ -139,7 +139,7 @@ int32_t RealEnvStore::Query(const char* key) const {
}

#ifdef _WIN32
if (key[0] == L'=') {
if (key[0] == '=') {
return static_cast<int32_t>(v8::ReadOnly) |
static_cast<int32_t>(v8::DontDelete) |
static_cast<int32_t>(v8::DontEnum);
Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-process-env.js
Expand Up @@ -106,3 +106,11 @@ if (common.isWindows) {
const keys = Object.keys(process.env);
assert.ok(keys.length > 0);
}

// Setting environment variables on Windows with empty names should not cause
// an assertion failure.
// https://github.com/nodejs/node/issues/32920
{
process.env[''] = '';
assert.strictEqual(process.env[''], undefined);
}