diff options
author | Trevor Norris <trev.norris@gmail.com> | 2016-04-13 13:16:42 -0600 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2016-05-24 14:40:22 -0600 |
commit | c0e6c668e6e6f0ba6a924a5b83ff1ca5434d14ad (patch) | |
tree | 2f24e1329abb6b5432273246b4754ec44e7b3e8a /src/fs_event_wrap.cc | |
parent | 13e5d4f32014e3426142580a699d0ffdf02db26a (diff) | |
download | node-new-c0e6c668e6e6f0ba6a924a5b83ff1ca5434d14ad.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/fs_event_wrap.cc')
-rw-r--r-- | src/fs_event_wrap.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index 48b6f4eca8..3f0df1140c 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -86,7 +86,8 @@ void FSEventWrap::New(const FunctionCallbackInfo<Value>& args) { void FSEventWrap::Start(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); - FSEventWrap* wrap = Unwrap<FSEventWrap>(args.Holder()); + FSEventWrap* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); static const char kErrMsg[] = "filename must be a string or Buffer"; if (args.Length() < 1) @@ -181,7 +182,8 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename, void FSEventWrap::Close(const FunctionCallbackInfo<Value>& args) { - FSEventWrap* wrap = Unwrap<FSEventWrap>(args.Holder()); + FSEventWrap* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); if (wrap == nullptr || wrap->initialized_ == false) return; |