From 81a0e90a502faf9edebc63f54fce51aae4397e72 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 12 Nov 2017 21:47:20 +1100 Subject: src/loslib.js: Check that var exists in process.env before indexing Solves issues with os.getenv'hasOwnProperty' --- src/loslib.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/loslib.js b/src/loslib.js index 745bbab..4d549b6 100644 --- a/src/loslib.js +++ b/src/loslib.js @@ -178,7 +178,11 @@ if (!WEB) { syslib.getenv = function(L) { let key = lauxlib.luaL_checkstring(L, 1); key = lua.to_jsstring(key); /* https://github.com/nodejs/node/issues/16961 */ - lua.lua_pushliteral(L, process.env[key]); /* if NULL push nil */ + if (Object.prototype.hasOwnProperty.call(process.env, key)) { + lua.lua_pushliteral(L, process.env[key]); + } else { + lua.lua_pushnil(L); + } return 1; }; -- cgit v1.2.3-70-g09d2