diff options
author | Trevor Norris <trev.norris@gmail.com> | 2016-04-13 22:16:42 +0300 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2016-05-24 23:40:22 +0300 |
commit | c0e6c668e6e6f0ba6a924a5b83ff1ca5434d14ad (patch) | |
tree | 2f24e1329abb6b5432273246b4754ec44e7b3e8a /src/node_stat_watcher.cc | |
parent | 13e5d4f32014e3426142580a699d0ffdf02db26a (diff) |
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 4fa01794f6c..cff92e34045 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); |