Bug 1266033: |nsDBusHandlerApp|: Hold reference to |DBusConnection| in |RefPtr|, r=bz
authorThomas Zimmermann <tdz@users.sourceforge.net>
Thu, 21 Apr 2016 11:24:23 +0200
changeset 294263 e65d8d0f3f5dade3c6b804ec5ff399965cbfe30b
parent 294262 43730c92b372c49ed462a733ff517a41037a282b
child 294264 2eff1cd6a1fe3e75a76affa174444ae59864c16f
push id30201
push userkwierso@gmail.com
push dateThu, 21 Apr 2016 21:41:56 +0000
treeherdermozilla-central@0891f0fa044c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 |DBusConnection| in |RefPtr|, r=bz |nsDBusHandlerApp| currently leaks its DBus connection. This patch fixes the leak with automated reference-counting by using |RefPtr|.
--- a/uriloader/exthandler/nsDBusHandlerApp.cpp
+++ b/uriloader/exthandler/nsDBusHandlerApp.cpp
@@ -1,15 +1,16 @@
 /* -*- 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 <dbus/dbus.h>
+#include "mozilla/ipc/DBusConnectionRefPtr.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?
@@ -81,18 +82,19 @@ nsDBusHandlerApp::LaunchWithURI(nsIURI *
   nsAutoCString spec;
   nsresult rv = aURI->GetAsciiSpec(spec);
   const char* uri = spec.get();
   DBusError err;
-  DBusConnection  *connection;
-  connection = dbus_bus_get(DBUS_BUS_SESSION, &err);
+  RefPtr<DBusConnection> connection = already_AddRefed<DBusConnection>(
+    dbus_bus_get(DBUS_BUS_SESSION, &err));
   if (dbus_error_is_set(&err)) {
     return NS_ERROR_FAILURE;
   if (nullptr == connection) {
     return NS_ERROR_FAILURE;