# Fix possible GC crash bugs

This was SVN commit r7546.
This commit is contained in:
Ykkrosh 2010-05-15 11:21:40 +00:00
parent a6600185ff
commit ae08adc55d
2 changed files with 3 additions and 5 deletions

View File

@ -85,7 +85,8 @@ CScriptVal GuiInterfaceCall(void* cbdata, std::wstring name, CScriptVal data)
if (g_Game && g_Game->GetLocalPlayer())
player = g_Game->GetLocalPlayer()->GetPlayerID();
CScriptVal ret = gui->ScriptCall(player, name, sim->GetScriptInterface().CloneValueFromOtherContext(guiManager->GetScriptInterface(), data.get()));
CScriptValRooted arg (sim->GetScriptInterface().GetContext(), sim->GetScriptInterface().CloneValueFromOtherContext(guiManager->GetScriptInterface(), data.get()));
CScriptVal ret (gui->ScriptCall(player, name, arg.get()));
return guiManager->GetScriptInterface().CloneValueFromOtherContext(sim->GetScriptInterface(), ret.get());
}

View File

@ -80,13 +80,10 @@ static jsval ConvertCParamNode(JSContext* cx, CParamNode const& val)
// Got child nodes - convert this node into a hash-table-style object:
ScriptInterface::LocalRootScope scope(cx);
if (!scope.OK())
return JSVAL_VOID; // TODO: report error
JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
if (!obj)
return JSVAL_VOID; // TODO: report error
CScriptValRooted objRoot(cx, OBJECT_TO_JSVAL(obj));
for (std::map<std::string, CParamNode>::const_iterator it = children.begin(); it != children.end(); ++it)
{