Backed out changeset 99eb8a370b21 (bug 952840) for permament B2G ICS Emulator Opt test failure
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 07 Jan 2014 13:46:20 +0100
changeset 162356 ce408ac339c5af0f028ef408714e9d1e6dd47caf
parent 162355 a1ed0445a56857c3af4b897c043a5ea14e676477
child 162357 8cdeb1bcdb028adc1bc9c02104756924949a5a1f
child 162358 d0553cb6729bd41bd560cc216db6433dc71b25c5
push idunknown
push userunknown
push dateunknown
bugs952840
milestone29.0a1
backs out99eb8a370b2107ecdb7ab62a55336ad6582a795e
Backed out changeset 99eb8a370b21 (bug 952840) for permament B2G ICS Emulator Opt test failure
js/xpconnect/src/XPCWrappedNative.cpp
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -1508,24 +1508,27 @@ XPCWrappedNative::FindTearOff(XPCNativeI
     to = firstAvailable;
 
     if (!to) {
         auto newChunk = new XPCWrappedNativeTearOffChunk();
         lastChunk->mNextChunk = newChunk;
         to = newChunk->mTearOffs;
     }
 
-    AutoMarkingWrappedNativeTearOffPtr tearoff(cx, to);
-    rv = InitTearOff(to, aInterface, needJSObject);
-    // During shutdown, we don't sweep tearoffs.  So make sure to unmark
-    // manually in case the auto-marker marked us.  We shouldn't ever be
-    // getting here _during_ our Mark/Sweep cycle, so this should be safe.
-    to->Unmark();
-    if (NS_FAILED(rv))
-        to = nullptr;
+    {
+        // Scope keeps |tearoff| from leaking across the rest of the function.
+        AutoMarkingWrappedNativeTearOffPtr tearoff(cx, to);
+        rv = InitTearOff(to, aInterface, needJSObject);
+        // During shutdown, we don't sweep tearoffs.  So make sure to unmark
+        // manually in case the auto-marker marked us.  We shouldn't ever be
+        // getting here _during_ our Mark/Sweep cycle, so this should be safe.
+        to->Unmark();
+        if (NS_FAILED(rv))
+            to = nullptr;
+    }
 
     if (pError)
         *pError = rv;
     return to;
 }
 
 nsresult
 XPCWrappedNative::InitTearOff(XPCWrappedNativeTearOff* aTearOff,