diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp index 7a6f71af40f..297884a1dc1 100644 --- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -1513,17 +1513,14 @@ XPCWrappedNative::FindTearOff(XPCNativeInterface* aInterface, to = newChunk->mTearOffs; } - { - // 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; - } + 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;