Bug 921553. Fix some binding rooting hazards that have popped up. r=peterv

This commit is contained in:
Boris Zbarsky 2013-09-30 10:29:10 -04:00
parent 44f1bc368f
commit 51daf6d4ad
2 changed files with 12 additions and 6 deletions

View File

@ -2085,7 +2085,7 @@ ConvertJSValueToByteString(JSContext* cx, JS::Handle<JS::Value> v,
JS::MutableHandle<JS::Value> pval, bool nullable,
nsACString& result)
{
JSString *s;
JS::Rooted<JSString*> s(cx);
if (v.isString()) {
s = v.toString();
} else {

View File

@ -6151,18 +6151,24 @@ def getUnionTypeTemplateVars(unionType, type, descriptorProvider,
body=body)
else:
# Important: we need to not have our declName involve
# maybe-GCing operations.
jsConversion = string.Template(conversionInfo.template).substitute(
{
"val": "value",
"mutableVal": "pvalue",
"declName": "SetAs" + name + "(%s)" % ctorArgs,
"declName": "memberSlot",
"holderName": "m" + name + "Holder",
}
)
jsConversion = CGWrapper(CGGeneric(jsConversion),
pre="tryNext = false;\n",
post="\n"
"return true;")
jsConversion = CGWrapper(CGIndenter(CGGeneric(jsConversion)),
pre=("tryNext = false;\n"
"{ // scope for memberSlot\n"
" %s& memberSlot = SetAs%s(%s);\n"
% (structType, name, ctorArgs)),
post=("\n"
"}\n"
"return true;"))
setter = ClassMethod("TrySetTo" + name, "bool",
[Argument("JSContext*", "cx"),
Argument("JS::Handle<JS::Value>", "value"),