Bug 1291019 - Take the value of |aDoomed| in NS_ReleaseOnMainThread() if we're going to leak anyway. r=froydnj
authorSeth Fowler <mark.seth.fowler@gmail.com>
Mon, 01 Aug 2016 15:25:58 -0700
changeset 395377 4c6dc34d653dfcf789e1782e0ead3c7d1c50d81d
parent 395376 8351f6e097ebecc28be5b1e8314d4fbed3fb2528
child 395378 7cfbd0d2d797490a88bff3fd1094683eaad3692e
push id24763
push userbmo:mh+mozilla@glandium.org
push dateTue, 02 Aug 2016 04:27:00 +0000
reviewersfroydnj
bugs1291019
milestone51.0a1
Bug 1291019 - Take the value of |aDoomed| in NS_ReleaseOnMainThread() if we're going to leak anyway. r=froydnj
xpcom/glue/nsProxyRelease.h
--- a/xpcom/glue/nsProxyRelease.h
+++ b/xpcom/glue/nsProxyRelease.h
@@ -11,16 +11,17 @@
 #include "nsIThread.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "MainThreadUtils.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Move.h"
 #include "mozilla/TypeTraits.h"
+#include "mozilla/unused.h"
 
 #ifdef XPCOM_GLUE_AVOID_NSPR
 #error NS_ProxyRelease implementation depends on NSPR.
 #endif
 
 namespace detail {
 
 template<typename T>
@@ -143,17 +144,18 @@ NS_ReleaseOnMainThread(already_AddRefed<
   // NS_ProxyRelease treats a null event target as "the current thread".  So a
   // handle on the main thread is only necessary when we're not already on the
   // main thread or the release must happen asynchronously.
   nsCOMPtr<nsIThread> mainThread;
   if (!NS_IsMainThread() || aAlwaysProxy) {
     nsresult rv = NS_GetMainThread(getter_AddRefs(mainThread));
 
     if (NS_FAILED(rv)) {
-      NS_WARNING("Could not get main thread! Leaking.");
+      MOZ_ASSERT_UNREACHABLE("Could not get main thread; leaking an object!");
+      mozilla::Unused << aDoomed.take();
       return;
     }
   }
 
   NS_ProxyRelease(mainThread, mozilla::Move(aDoomed), aAlwaysProxy);
 }
 
 /**