diff options
author | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2019-10-29 18:59:09 -0700 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-11-08 15:53:35 +0100 |
commit | 3429e0178ddb1eb2b288344060db707fefb2da0e (patch) | |
tree | 64e6b49bca78dc14240c3305627edfb901419947 /deps | |
parent | 186f15771c7a83d32c9589b7ff8f055b318c9589 (diff) | |
download | android-node-v8-3429e0178ddb1eb2b288344060db707fefb2da0e.tar.gz android-node-v8-3429e0178ddb1eb2b288344060db707fefb2da0e.tar.bz2 android-node-v8-3429e0178ddb1eb2b288344060db707fefb2da0e.zip |
deps: V8: cherry-pick e5dbc95
Original commit message:
[api] Fix handle leak when getting Context embedder data
The `Context::SlowGetAlignedPointerFromEmbedderData()` method returns
a pointer, so the fact that it allocates handles is not obvious to
the caller.
Since this is the slow path anyway, simply add a handle scope inside
of it.
The tests are also modified to perform the same check for the
`Object` equivalent of this method.
Change-Id: I5f03c9a7b70b3a17315609df021606a53c9feb2d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1879902
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64583}
Refs: https://github.com/v8/v8/commit/e5dbc95cc0bfbd8a3b6d67b9e4ed920cf3c9fe27
Fixes: https://github.com/nodejs/node/issues/30127
PR-URL: https://github.com/nodejs/node/pull/30130
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Diffstat (limited to 'deps')
-rw-r--r-- | deps/v8/src/api/api.cc | 1 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-api.cc | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc index fffee36c5a..eed4ee6d9d 100644 --- a/deps/v8/src/api/api.cc +++ b/deps/v8/src/api/api.cc @@ -1314,6 +1314,7 @@ void Context::SetEmbedderData(int index, v8::Local<Value> value) { void* Context::SlowGetAlignedPointerFromEmbedderData(int index) { const char* location = "v8::Context::GetAlignedPointerFromEmbedderData()"; + HandleScope handle_scope(GetIsolate()); i::Handle<i::EmbedderDataArray> data = EmbedderDataFor(this, index, false, location); if (data.is_null()) return nullptr; diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 7da247e3ab..12faaff39c 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -2956,8 +2956,11 @@ THREADED_TEST(SetAlignedPointerInInternalFields) { obj->SetAlignedPointerInInternalFields(2, indices, values); CcTest::CollectAllGarbage(); - CHECK_EQ(heap_allocated_1, obj->GetAlignedPointerFromInternalField(0)); - CHECK_EQ(heap_allocated_2, obj->GetAlignedPointerFromInternalField(1)); + { + v8::SealHandleScope no_handle_leak(isolate); + CHECK_EQ(heap_allocated_1, obj->GetAlignedPointerFromInternalField(0)); + CHECK_EQ(heap_allocated_2, obj->GetAlignedPointerFromInternalField(1)); + } indices[0] = 1; indices[1] = 0; @@ -3010,6 +3013,7 @@ THREADED_TEST(EmbedderDataAlignedPointers) { } CcTest::CollectAllGarbage(); for (int i = 0; i < 100; i++) { + v8::SealHandleScope no_handle_leak(env->GetIsolate()); CHECK_EQ(AlignedTestPointer(i), env->GetAlignedPointerFromEmbedderData(i)); } } |