From 8747b1c098ff917ee26074170583427633b93f50 Mon Sep 17 00:00:00 2001 From: Itms Date: Fri, 2 Sep 2016 16:33:10 +0000 Subject: [PATCH] SpiderMonkey 38 upgrade: 17/35 JS_GetUint*Array now takes an AutoCheckCannotGC parameter. Based on patch by leper. Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1061288 This was SVN commit r18671. --- .../scripting/EngineScriptConversions.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/simulation2/scripting/EngineScriptConversions.cpp b/source/simulation2/scripting/EngineScriptConversions.cpp index 02661b21a6..b7f2e28870 100644 --- a/source/simulation2/scripting/EngineScriptConversions.cpp +++ b/source/simulation2/scripting/EngineScriptConversions.cpp @@ -253,7 +253,11 @@ template<> void ScriptInterface::ToJSVal >(JSContext* cx, JS::MutableHa u32 length = (u32)(val.m_W * val.m_H); u32 nbytes = (u32)(length * sizeof(u8)); JS::RootedObject objArr(cx, JS_NewUint8Array(cx, length)); - memcpy((void*)JS_GetUint8ArrayData(objArr), val.m_Data, nbytes); + // Copy the array data and then remove the no-GC check to allow further changes to the JS data + { + JS::AutoCheckCannotGC nogc; + memcpy((void*)JS_GetUint8ArrayData(objArr, nogc), val.m_Data, nbytes); + } JS::RootedValue data(cx, JS::ObjectValue(*objArr)); JS::RootedValue w(cx); @@ -275,7 +279,11 @@ template<> void ScriptInterface::ToJSVal >(JSContext* cx, JS::MutableH u32 length = (u32)(val.m_W * val.m_H); u32 nbytes = (u32)(length * sizeof(u16)); JS::RootedObject objArr(cx, JS_NewUint16Array(cx, length)); - memcpy((void*)JS_GetUint16ArrayData(objArr), val.m_Data, nbytes); + // Copy the array data and then remove the no-GC check to allow further changes to the JS data + { + JS::AutoCheckCannotGC nogc; + memcpy((void*)JS_GetUint16ArrayData(objArr, nogc), val.m_Data, nbytes); + } JS::RootedValue data(cx, JS::ObjectValue(*objArr)); JS::RootedValue w(cx);