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);