From 5d922cce8adc7795efd0eadfcb21b6b0b70538a8 Mon Sep 17 00:00:00 2001 From: Chris Loer Date: Fri, 23 Feb 2018 16:24:29 -0800 Subject: [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 --- platform/node/src/node_map.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index ac14df0228..0fe69e8ac9 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -1154,6 +1154,10 @@ NodeMap::~NodeMap() { std::unique_ptr 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 argv[] = { Nan::New(this), -- cgit v1.2.1