Bug 1231677 - verify the return of mDiscoveryTimer->Init, if it faild exit function with error code. r=jst
authorBogdan Postelnicu <bogdan.postelnicu>
Thu, 10 Dec 2015 07:56:00 +0100
changeset 315801 094fd5a4d3dced8b18c171fa47453e823f387de6
parent 315800 0bff21e6da0724c70f394e7835db1577fb302dcc
child 315802 1f2dd09046144ec617ce1ceba970699f0f8043fc
push id8468
push userhurley@todesschaf.org
push dateWed, 16 Dec 2015 19:25:06 +0000
reviewersjst
bugs1231677
milestone46.0a1
Bug 1231677 - verify the return of mDiscoveryTimer->Init, if it faild exit function with error code. r=jst
dom/presentation/provider/MulticastDNSDeviceProvider.cpp
--- a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp
+++ b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp
@@ -571,28 +571,30 @@ MulticastDNSDeviceProvider::ForceDiscove
   if (!mDiscoveryEnabled) {
     return NS_OK;
   }
 
   MOZ_ASSERT(mDiscoveryTimer);
   MOZ_ASSERT(mMulticastDNS);
 
   // if it's already discovering, extend existing discovery timeout.
+  nsresult rv;
   if (mIsDiscovering) {
     Unused << mDiscoveryTimer->Cancel();
 
-    NS_WARN_IF(NS_FAILED(mDiscoveryTimer->Init(this,
-                                               mDiscveryTimeoutMs,
-                                               nsITimer::TYPE_ONE_SHOT)));
+    if (NS_WARN_IF(NS_FAILED( rv = mDiscoveryTimer->Init(this,
+        mDiscveryTimeoutMs,
+        nsITimer::TYPE_ONE_SHOT)))) {
+        return rv;
+    }
     return NS_OK;
   }
 
   StopDiscovery(NS_OK);
 
-  nsresult rv;
   if (NS_WARN_IF(NS_FAILED(rv = mMulticastDNS->StartDiscovery(
       NS_LITERAL_CSTRING(SERVICE_TYPE),
       mWrappedListener,
       getter_AddRefs(mDiscoveryRequest))))) {
     return rv;
   }
 
   return NS_OK;