diff options
author | Trevor Norris <trev.norris@gmail.com> | 2016-04-13 13:16:42 -0600 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2016-06-02 22:39:22 +1000 |
commit | 4333fda46d1feaab4afb75f31349f21c0c62fc40 (patch) | |
tree | 7ee66ee20043508961b9132385fe9f8f39d849df /src/node_stat_watcher.cc | |
parent | 0d08fc415f12a4ea8babfad0d72ccda50a3e2c25 (diff) | |
download | node-new-4333fda46d1feaab4afb75f31349f21c0c62fc40.tar.gz |
src: no abort from getter if object isn't wrapped
v8::Object::GetAlignedPointerFromInternalField() returns a random value
if Wrap() hasn't been run on the object handle. Causing v8 to abort if
certain getters are accessed. It's possible to access these getters and
functions during class construction through the AsyncWrap init()
callback, and also possible in a subset of those scenarios while running
the persistent handle visitor.
Mitigate this issue by manually setting the internal aligned pointer
field to nullptr in the BaseObject constructor and add necessary logic
to return appropriate values when nullptr is encountered.
PR-URL: https://github.com/nodejs/node/pull/6184
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/node_stat_watcher.cc')
-rw-r--r-- | src/node_stat_watcher.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/node_stat_watcher.cc b/src/node_stat_watcher.cc index 4fa01794f6..cff92e3404 100644 --- a/src/node_stat_watcher.cc +++ b/src/node_stat_watcher.cc @@ -84,7 +84,8 @@ void StatWatcher::New(const FunctionCallbackInfo<Value>& args) { void StatWatcher::Start(const FunctionCallbackInfo<Value>& args) { CHECK_EQ(args.Length(), 3); - StatWatcher* wrap = Unwrap<StatWatcher>(args.Holder()); + StatWatcher* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); node::Utf8Value path(args.GetIsolate(), args[0]); const bool persistent = args[1]->BooleanValue(); const uint32_t interval = args[2]->Uint32Value(); @@ -97,7 +98,8 @@ void StatWatcher::Start(const FunctionCallbackInfo<Value>& args) { void StatWatcher::Stop(const FunctionCallbackInfo<Value>& args) { - StatWatcher* wrap = Unwrap<StatWatcher>(args.Holder()); + StatWatcher* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); Environment* env = wrap->env(); Context::Scope context_scope(env->context()); wrap->MakeCallback(env->onstop_string(), 0, nullptr); |