summaryrefslogtreecommitdiff
path: root/src/handle_wrap.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-01-09 20:39:06 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2012-01-09 20:54:37 +0100
commitd5d043f2d72e88669e2e3621651153316831034e (patch)
treec41f69fc64b4190d8c17a2690da6e47d2b3e441f /src/handle_wrap.cc
parentcc5cea35b0e25352ff40780532d4c5a6bba00359 (diff)
downloadandroid-node-v8-d5d043f2d72e88669e2e3621651153316831034e.tar.gz
android-node-v8-d5d043f2d72e88669e2e3621651153316831034e.tar.bz2
android-node-v8-d5d043f2d72e88669e2e3621651153316831034e.zip
handle_wrap: guard against uninitialized handle or double close
Diffstat (limited to 'src/handle_wrap.cc')
-rw-r--r--src/handle_wrap.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc
index 5b6594a3a9..eb6713edad 100644
--- a/src/handle_wrap.cc
+++ b/src/handle_wrap.cc
@@ -99,9 +99,11 @@ Handle<Value> HandleWrap::Close(const Arguments& args) {
UNWRAP
+ // guard against uninitialized handle or double close
+ if (wrap->handle__ == NULL) return v8::Null();
assert(!wrap->object_.IsEmpty());
uv_close(wrap->handle__, OnClose);
-
+ wrap->handle__ = NULL;
HandleWrap::Ref(args);
@@ -143,6 +145,9 @@ void HandleWrap::OnClose(uv_handle_t* handle) {
// The wrap object should still be there.
assert(wrap->object_.IsEmpty() == false);
+ // But the handle pointer should be gone.
+ assert(wrap->handle__ == NULL);
+
wrap->object_->SetPointerInInternalField(0, NULL);
wrap->object_.Dispose();
wrap->object_.Clear();