Skip to content

Commit

Permalink
use AutoSafeJSContext to not crash in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeshkova committed Mar 6, 2014
1 parent f3ec04a commit 8e3fe04
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions embedding/embedlite/modules/EmbedLiteJSON.cpp
Expand Up @@ -208,15 +208,8 @@ static bool SetPropFromVariant(nsIProperty* aProp, JSContext* aCx, JSObject* aOb
NS_IMETHODIMP
EmbedLiteJSON::CreateJSON(nsIPropertyBag* aRoot, nsAString& outJson)
{
XPCJSContextStack* stack = XPCJSRuntime::Get()->GetJSContextStack();
JSContext* cx = stack->GetSafeJSContext();
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);

JSObject* global = GetDefaultScopeFromJSContext(cx);
JSAutoCompartment ac(cx, global);

JSAutoRequest ar(cx);
JSObject* obj = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
AutoSafeJSContext cx;
JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
if (!obj) {
return NS_ERROR_FAILURE;
}
Expand Down

0 comments on commit 8e3fe04

Please sign in to comment.