diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-09-14 02:34:10 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-09-14 02:37:51 +0200 |
commit | db5c26e3b57c5c0c5c3e84931bc73b701f0258d1 (patch) | |
tree | a619babfb7cc9dff3250fc0cea582b00ea8f5aa7 /src | |
parent | 07804c7c9a4c2eb50eb897fa5e41cb8c9e5a1ab5 (diff) | |
download | node-db5c26e3b57c5c0c5c3e84931bc73b701f0258d1.tar.gz |
fs: fix assert in fs.watch()
Fix the following error:
FSEventWrap: Aborting due to unwrap failure at ../../src/fs_event_wrap.cc:169
It's possible and legal for a handle to be closed twice. HandleWrap::Close()
deals with that by ignoring the second close. Now FSEventWrap::Close() does
too.
Fixes #3997.
Diffstat (limited to 'src')
-rw-r--r-- | src/fs_event_wrap.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index adac00c9f..bb4573300 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -166,12 +166,17 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename, Handle<Value> FSEventWrap::Close(const Arguments& args) { HandleScope scope; - UNWRAP(FSEventWrap) - - if (!wrap->initialized_) - return Undefined(); - + // Unwrap manually here. The UNWRAP() macro asserts that wrap != NULL. + // That usually indicates an error but not here: double closes are possible + // and legal, HandleWrap::Close() deals with them the same way. + assert(!args.Holder().IsEmpty()); + assert(args.Holder()->InternalFieldCount() > 0); + void* ptr = args.Holder()->GetPointerFromInternalField(0); + FSEventWrap* wrap = static_cast<FSEventWrap*>(ptr); + + if (wrap == NULL || wrap->initialized_ == false) return Undefined(); wrap->initialized_ = false; + return HandleWrap::Close(args); } |