Bug 1435306 followup - Fix rooting hazard. r=red CLOSED TREE
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 06 Feb 2018 15:17:18 +0100
changeset 751778 cefac2e7eb0c3e22bd4a69833aba1d677a0ff3e9
parent 751777 b5cfc56349734b20935ff9d89dc7028933ea8856
child 751779 27a1bfb7e7927374f349a9369282ece46ba71172
push id98047
push userbmo:continuation@gmail.com
push dateTue, 06 Feb 2018 22:02:37 +0000
reviewersred
bugs1435306
milestone60.0a1
Bug 1435306 followup - Fix rooting hazard. r=red CLOSED TREE
js/src/builtin/intl/PluralRules.cpp
--- a/js/src/builtin/intl/PluralRules.cpp
+++ b/js/src/builtin/intl/PluralRules.cpp
@@ -126,21 +126,25 @@ PluralRules(JSContext* cx, unsigned argc
 void
 js::PluralRulesObject::finalize(FreeOp* fop, JSObject* obj)
 {
     MOZ_ASSERT(fop->onActiveCooperatingThread());
 
     PluralRulesObject* pluralRules = &obj->as<PluralRulesObject>();
 
     const Value& prslot = pluralRules->getReservedSlot(PluralRulesObject::UPLURAL_RULES_SLOT);
-    if (UPluralRules* pr = static_cast<UPluralRules*>(prslot.toPrivate()))
+    UPluralRules* pr = static_cast<UPluralRules*>(prslot.toPrivate());
+
+    const Value& nfslot = pluralRules->getReservedSlot(PluralRulesObject::UNUMBER_FORMAT_SLOT);
+    UNumberFormat* nf = static_cast<UNumberFormat*>(nfslot.toPrivate());
+
+    if (pr)
         uplrules_close(pr);
 
-    const Value& nfslot = pluralRules->getReservedSlot(PluralRulesObject::UNUMBER_FORMAT_SLOT);
-    if (UNumberFormat* nf = static_cast<UNumberFormat*>(nfslot.toPrivate()))
+    if (nf)
         unum_close(nf);
 }
 
 JSObject*
 js::CreatePluralRulesPrototype(JSContext* cx, HandleObject Intl, Handle<GlobalObject*> global)
 {
     RootedFunction ctor(cx);
     ctor = global->createConstructor(cx, &PluralRules, cx->names().PluralRules, 0);