summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-02-23 16:24:29 -0800
committerChris Loer <chris.loer@mapbox.com>2018-02-26 14:23:01 -0800
commit7097e04fb359e8351e330e248bb876bc84c4513b (patch)
treefbc4e0209494d20c2f95922dafbd5e74c0a49c40
parent91f6e09dadd09926508b88083fc3f5d9a8da9226 (diff)
downloadqtlocation-mapboxgl-7097e04fb359e8351e330e248bb876bc84c4513b.tar.gz
[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
-rw-r--r--platform/node/src/node_map.cpp4
1 files changed, 4 insertions, 0 deletions
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<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),