diff options
author | Sakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com> | 2016-12-26 16:42:09 +0530 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-03-22 15:02:43 -0700 |
commit | caf9ae748b1324c34284b324f2951b91368ca840 (patch) | |
tree | 9279dc83f97af9aa417a18e543a2b3eb34db3d8a /src | |
parent | 221b03ad20453f08cef7ac3fcc788b8466edc3ef (diff) | |
download | android-node-v8-caf9ae748b1324c34284b324f2951b91368ca840.tar.gz android-node-v8-caf9ae748b1324c34284b324f2951b91368ca840.tar.bz2 android-node-v8-caf9ae748b1324c34284b324f2951b91368ca840.zip |
lib,src: make constants not inherit from Object
Make sure `constants` object and all the nested objects don't inherit
from `Object.prototype` but from `null`.
PR-URL: https://github.com/nodejs/node/pull/10458
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/node.cc | 2 | ||||
-rw-r--r-- | src/node_constants.cc | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc index d79b8ee30e..52bf719852 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2673,6 +2673,8 @@ static void Binding(const FunctionCallbackInfo<Value>& args) { cache->Set(module, exports); } else if (!strcmp(*module_v, "constants")) { exports = Object::New(env->isolate()); + CHECK(exports->SetPrototype(env->context(), + Null(env->isolate())).FromJust()); DefineConstants(env->isolate(), exports); cache->Set(module, exports); } else if (!strcmp(*module_v, "natives")) { diff --git a/src/node_constants.cc b/src/node_constants.cc index bed87b7649..5bde53fcdf 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -1245,12 +1245,31 @@ void DefineZlibConstants(Local<Object> target) { } void DefineConstants(v8::Isolate* isolate, Local<Object> target) { + Environment* env = Environment::GetCurrent(isolate); + Local<Object> os_constants = Object::New(isolate); + CHECK(os_constants->SetPrototype(env->context(), + Null(env->isolate())).FromJust()); + Local<Object> err_constants = Object::New(isolate); + CHECK(err_constants->SetPrototype(env->context(), + Null(env->isolate())).FromJust()); + Local<Object> sig_constants = Object::New(isolate); + CHECK(sig_constants->SetPrototype(env->context(), + Null(env->isolate())).FromJust()); + Local<Object> fs_constants = Object::New(isolate); + CHECK(fs_constants->SetPrototype(env->context(), + Null(env->isolate())).FromJust()); + Local<Object> crypto_constants = Object::New(isolate); + CHECK(crypto_constants->SetPrototype(env->context(), + Null(env->isolate())).FromJust()); + Local<Object> zlib_constants = Object::New(isolate); + CHECK(zlib_constants->SetPrototype(env->context(), + Null(env->isolate())).FromJust()); DefineErrnoConstants(err_constants); DefineWindowsErrorConstants(err_constants); |