[node] enter new v8::Context to avoid leaking v8::FunctionTemplate in NodeMap::request

This commit is contained in:
Mike Morris
2016-07-12 16:16:45 -04:00
parent 70337487d4
commit ce8f053adb

View File

@@ -757,7 +757,12 @@ NodeMap::~NodeMap() {
}
std::unique_ptr<mbgl::AsyncRequest> NodeMap::request(const mbgl::Resource& resource, Callback callback_) {
Nan::HandleScope scope;
Nan::HandleScope handleScope;
// Enter a new v8::Context to avoid leaking v8::FunctionTemplate
// from Nan::New<v8::Function>
v8::Local<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent());
v8::Context::Scope scope(context);
auto requestHandle = NodeRequest::Create(resource, callback_)->ToObject();
auto request = Nan::ObjectWrap::Unwrap<NodeRequest>(requestHandle);