Bug 1266033: |nsDBusHandlerApp|: Hold reference to |DBusMessage| in |RefPtr|, r=bz
authorThomas Zimmermann <tdz@users.sourceforge.net>
Thu, 21 Apr 2016 11:24:23 +0200
changeset 334125 2eff1cd6a1fe3e75a76affa174444ae59864c16f
parent 334124 e65d8d0f3f5dade3c6b804ec5ff399965cbfe30b
child 334126 8b76cbb69bef628b93c165c78a55c361ad3e5109
push id1146
push userCallek@gmail.com
push dateMon, 25 Jul 2016 16:35:44 +0000
treeherdermozilla-release@a55778f9cd5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1266033
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1266033: |nsDBusHandlerApp|: Hold reference to |DBusMessage| in |RefPtr|, r=bz
uriloader/exthandler/nsDBusHandlerApp.cpp
--- a/uriloader/exthandler/nsDBusHandlerApp.cpp
+++ b/uriloader/exthandler/nsDBusHandlerApp.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim:expandtab:shiftwidth=2:tabstop=2:cin:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <dbus/dbus.h>
 #include "mozilla/ipc/DBusConnectionRefPtr.h"
+#include "mozilla/ipc/DBusMessageRefPtr.h"
 #include "nsDBusHandlerApp.h"
 #include "nsIURI.h"
 #include "nsIClassInfoImpl.h"
 #include "nsCOMPtr.h"
 #include "nsCExternalHandlerService.h"
 
 // XXX why does nsMIMEInfoImpl have a threadsafe nsISupports?  do we need one
 // here too?
@@ -94,36 +95,34 @@ nsDBusHandlerApp::LaunchWithURI(nsIURI *
     dbus_error_free(&err);
     return NS_ERROR_FAILURE;
   }
   if (nullptr == connection) {
     return NS_ERROR_FAILURE;
   }
   dbus_connection_set_exit_on_disconnect(connection,false);
 
-  DBusMessage* msg;
-  msg = dbus_message_new_method_call(mService.get(),
-                                     mObjpath.get(),
-                                     mInterface.get(),
-                                     mMethod.get());
+  RefPtr<DBusMessage> msg = already_AddRefed<DBusMessage>(
+    dbus_message_new_method_call(mService.get(),
+                                 mObjpath.get(),
+                                 mInterface.get(),
+                                 mMethod.get()));
 
   if (!msg) {
     return NS_ERROR_FAILURE;
   }
   dbus_message_set_no_reply(msg, true);
 
   DBusMessageIter iter;
   dbus_message_iter_init_append(msg, &iter);
   dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &uri);
 
   if (dbus_connection_send(connection, msg, nullptr)) {
     dbus_connection_flush(connection);
-    dbus_message_unref(msg);
   } else {
-    dbus_message_unref(msg);
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 //// nsIDBusHandlerApp