summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-09-11 09:14:33 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-11 18:48:08 +0200
commita48ae1d629f4c7939f3421db969f43db6bab8e11 (patch)
tree0d286fbf47f68a01705bf2b29d486e807436eeb9
parent0a8af38cf0add7592bf8f491e45a5de8b125a190 (diff)
downloadqtjsbackend-a48ae1d629f4c7939f3421db969f43db6bab8e11.tar.gz
Fix rare crash when calling SetExternalResourceHEADstableold/5.1
This is a patch on top of the original patch that adds support for external resources to v8::Object. When the provided external resource pointer cannot be encoded in SMI, then we need to allocate an object on the heap to hold it. That in turn may trigger a garbage collection, which in turn may end up collecting the object itself. Similarly to other methods dealing with the allocation of i::Foreign, the insertion of a HandleScope is required. Done-with: Lars Task-Number: QTBUG-29127 Change-Id: I9a99998e2fbfcb8a4c1e31595344680123072c6b Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/3rdparty/v8/src/api.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/3rdparty/v8/src/api.cc b/src/3rdparty/v8/src/api.cc
index cbb3a04..baa5b0a 100644
--- a/src/3rdparty/v8/src/api.cc
+++ b/src/3rdparty/v8/src/api.cc
@@ -4421,11 +4421,13 @@ void v8::Object::SetPointerInInternalField(int index, void* value) {
void v8::Object::SetExternalResource(v8::Object::ExternalResource *resource) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
+ HandleScope scope;
i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
if (CanBeEncodedAsSmi(resource)) {
obj->SetExternalResourceObject(EncodeAsSmi(resource));
} else {
- obj->SetExternalResourceObject(*isolate->factory()->NewForeign(static_cast<i::Address>((void *)resource)));
+ i::Handle<i::Foreign> foreign = isolate->factory()->NewForeign(static_cast<i::Address>((void *)resource));
+ obj->SetExternalResourceObject(*foreign);
}
if (!obj->IsSymbol()) {
isolate->heap()->external_string_table()->AddObject(*obj);