mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-26 22:12:39 +00:00
Exact stack rooting for structured cloning functions.
Refs #2415 Refs #2462 This was SVN commit r15597.
This commit is contained in:
@@ -1256,6 +1256,9 @@ int CMapReader::LoadRMSettings()
|
||||
|
||||
int CMapReader::GenerateMap()
|
||||
{
|
||||
JSContext* cx = pSimulation2->GetScriptInterface().GetContext();
|
||||
JSAutoRequest rq(cx);
|
||||
|
||||
if (!m_MapGen)
|
||||
{
|
||||
// Initialize map generator
|
||||
@@ -1286,15 +1289,17 @@ int CMapReader::GenerateMap()
|
||||
shared_ptr<ScriptInterface::StructuredClone> results = m_MapGen->GetResults();
|
||||
|
||||
// Parse data into simulation context
|
||||
CScriptValRooted data(pSimulation2->GetScriptInterface().GetContext(), pSimulation2->GetScriptInterface().ReadStructuredClone(results));
|
||||
if (data.undefined())
|
||||
JS::RootedValue data(cx);
|
||||
pSimulation2->GetScriptInterface().ReadStructuredClone(results, &data);
|
||||
|
||||
if (data.isUndefined())
|
||||
{
|
||||
// RMS failed - return to main menu
|
||||
throw PSERROR_Game_World_MapLoadFailed("Error generating random map.\nCheck application log for details.");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MapData = data;
|
||||
m_MapData = CScriptValRooted(cx, data);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user