[core, node] Hold on to map handle during NodeMap::request.

Avoids a potential crash if garbage collection happens in the middle of a call to NodeMap::request from a map that's eligible for GC.
Fixes issue #11281
This commit is contained in:
Chris Loer
2018-02-23 16:24:29 -08:00
committed by Chris Loer
parent dfeb5b25d3
commit 8e1fc8ff38

View File

@@ -1154,6 +1154,10 @@ NodeMap::~NodeMap() {
std::unique_ptr<mbgl::AsyncRequest> NodeMap::request(const mbgl::Resource& resource, mbgl::FileSource::Callback callback_) {
Nan::HandleScope scope;
// Because this method may be called while this NodeMap is already eligible for garbage collection,
// we need to explicitly hold onto our own handle here so that GC during a v8 call doesn't destroy
// *this while we're still executing code.
handle();
v8::Local<v8::Value> argv[] = {
Nan::New<v8::External>(this),