From 4333fda46d1feaab4afb75f31349f21c0c62fc40 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 13 Apr 2016 13:16:42 -0600 Subject: 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 Reviewed-By: Anna Henningsen --- src/node_stat_watcher.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/node_stat_watcher.cc') 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& args) { void StatWatcher::Start(const FunctionCallbackInfo& args) { CHECK_EQ(args.Length(), 3); - StatWatcher* wrap = Unwrap(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& args) { void StatWatcher::Stop(const FunctionCallbackInfo& args) { - StatWatcher* wrap = Unwrap(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); -- cgit v1.2.1