summaryrefslogtreecommitdiff
path: root/src/node.h
diff options
context:
space:
mode:
authorC. Scott Ananian <cscott@cscott.net>2014-03-06 15:44:18 -0500
committerTrevor Norris <trev.norris@gmail.com>2014-04-02 01:48:34 -0700
commit08a5b442e42ff67bd5666604eebe69f1b4a1c919 (patch)
treeef08abc6ccc5fd1e07494b5074cf8b560c89f3cf /src/node.h
parentd4fcb23e38e74d21e04b3a17d10e52949b630ec0 (diff)
downloadandroid-node-v8-08a5b442e42ff67bd5666604eebe69f1b4a1c919.tar.gz
android-node-v8-08a5b442e42ff67bd5666604eebe69f1b4a1c919.tar.bz2
android-node-v8-08a5b442e42ff67bd5666604eebe69f1b4a1c919.zip
node: add signature to SET_PROTOTYPE_METHOD
This prevents segfaults when a native method is reassigned to a different object (which corrupts args.This()). When unwrapping, clients should use args.Holder() instead of args.This(). Closes #6690. Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src/node.h')
-rw-r--r--src/node.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/node.h b/src/node.h
index ff55cf19e3..5ba5aa9c86 100644
--- a/src/node.h
+++ b/src/node.h
@@ -212,8 +212,9 @@ inline void NODE_SET_PROTOTYPE_METHOD(v8::Handle<v8::FunctionTemplate> recv,
v8::FunctionCallback callback) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handle_scope(isolate);
- v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate,
- callback);
+ v8::Handle<v8::Signature> s = v8::Signature::New(isolate, recv);
+ v8::Local<v8::FunctionTemplate> t =
+ v8::FunctionTemplate::New(isolate, callback, v8::Handle<v8::Value>(), s);
recv->PrototypeTemplate()->Set(v8::String::NewFromUtf8(isolate, name),
t->GetFunction());
}