Bug 1418985 - pass valid error parameter to dbus_bus_request_name() instead of nullptr, r?jhorak draft
authorMartin Stransky <stransky@redhat.com>
Mon, 20 Nov 2017 15:24:11 +0100
changeset 700593 1acd362f1dbd6521fee8a8d05df995bed13bee78
parent 700338 dd08f8b19cc32da161811abb2f7093e0f5392e69
child 700594 0e38a0bc50ce1ae3379d1c9e21371bec9fe5190f
child 700595 a8ac6d116fd642b5e6719cb4bbf9c39fd4a6fe21
push id89899
push userstransky@redhat.com
push dateMon, 20 Nov 2017 14:24:35 +0000
reviewersjhorak
bugs1418985
milestone59.0a1
Bug 1418985 - pass valid error parameter to dbus_bus_request_name() instead of nullptr, r?jhorak MozReview-Commit-ID: 4Gv517107zt
toolkit/components/remote/nsDBusRemoteService.cpp
--- a/toolkit/components/remote/nsDBusRemoteService.cpp
+++ b/toolkit/components/remote/nsDBusRemoteService.cpp
@@ -167,23 +167,26 @@ nsDBusRemoteService::Startup(const char*
   if (!mConnection)
     return NS_ERROR_FAILURE;
 
   dbus_connection_set_exit_on_disconnect(mConnection, false);
 
   nsAutoCString interfaceName;
   interfaceName = nsPrintfCString("org.mozilla.%s.%s", aAppName, aProfileName);
 
-  int ret = dbus_bus_request_name(mConnection, interfaceName.get(),
-                                 DBUS_NAME_FLAG_DO_NOT_QUEUE, nullptr);
+  DBusError err;
+  dbus_error_init(&err);
+  dbus_bus_request_name(mConnection, interfaceName.get(),
+                       DBUS_NAME_FLAG_DO_NOT_QUEUE, &err);
   // The interface is already owned - there is another application/profile
   // instance already running.
-  if (ret == -1) {
-   mConnection = nullptr;
-   return NS_ERROR_FAILURE;
+  if (dbus_error_is_set(&err)) {
+    dbus_error_free(&err);
+    mConnection = nullptr;
+    return NS_ERROR_FAILURE;
   }
 
   nsAutoCString objectName;
   objectName = nsPrintfCString("/org/mozilla/%s/Remote", aAppName);
 
   if (!dbus_connection_register_object_path(mConnection, objectName.get(),
                                            &remoteHandlersTable, this)) {
     mConnection = nullptr;