| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 450f5f4 commit cec3d1e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2916,6 +2916,7 @@ static void EnvGetter(Local<Name> property, | |||
| 2916 | 2916 | #else // _WIN32 | |
| 2917 | 2917 | node::TwoByteValue key(isolate, property); | |
| 2918 | 2918 | WCHAR buffer[32767]; // The maximum size allowed for environment variables. | |
| 2919 | + SetLastError(ERROR_SUCCESS); | ||
| 2919 | 2920 | DWORD result = GetEnvironmentVariableW(reinterpret_cast<WCHAR*>(*key), | |
| 2920 | 2921 | buffer, | |
| 2921 | 2922 | arraysize(buffer)); | |
@@ -2964,6 +2965,7 @@ static void EnvQuery(Local<Name> property, | |||
| 2964 | 2965 | #else // _WIN32 | |
| 2965 | 2966 | node::TwoByteValue key(info.GetIsolate(), property); | |
| 2966 | 2967 | WCHAR* key_ptr = reinterpret_cast<WCHAR*>(*key); | |
| 2968 | + SetLastError(ERROR_SUCCESS); | ||
| 2967 | 2969 | if (GetEnvironmentVariableW(key_ptr, nullptr, 0) > 0 || | |
| 2968 | 2970 | GetLastError() == ERROR_SUCCESS) { | |
| 2969 | 2971 | rc = 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,22 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + | ||
| 5 | + // This checks that after accessing a missing env var, a subsequent | ||
| 6 | + // env read will succeed even for empty variables. | ||
| 7 | + | ||
| 8 | + { | ||
| 9 | + process.env.FOO = ''; | ||
| 10 | + process.env.NONEXISTENT_ENV_VAR; | ||
| 11 | + const foo = process.env.FOO; | ||
| 12 | + | ||
| 13 | + assert.strictEqual(foo, ''); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + { | ||
| 17 | + process.env.FOO = ''; | ||
| 18 | + process.env.NONEXISTENT_ENV_VAR; | ||
| 19 | + const hasFoo = 'FOO' in process.env; | ||
| 20 | + | ||
| 21 | + assert.strictEqual(hasFoo, true); | ||
| 22 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments