Bug 753134 - B2G bluetooth interface crashes when trying to remove non-existent dbus watch sockets; r=mwu
authorKyle Machulis <kyle@nonpolynomial.com>
Wed, 09 May 2012 16:33:56 -0700
changeset 93659 ab315de0070f64c19540f9dd256736a0796dcc00
parent 93658 2cf8b1f792cec4be949c633d1face3a519b158a2
child 93660 2ce1d975d874179f687b811c17590b244e4eeb38
push id22658
push useremorley@mozilla.com
push dateThu, 10 May 2012 12:06:32 +0000
treeherdermozilla-central@b7b6565d12a0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmwu
bugs753134
milestone15.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 753134 - B2G bluetooth interface crashes when trying to remove non-existent dbus watch sockets; r=mwu
ipc/dbus/DBusThread.cpp
--- a/ipc/dbus/DBusThread.cpp
+++ b/ipc/dbus/DBusThread.cpp
@@ -271,16 +271,24 @@ static void HandleWatchRemove(DBusThread
     LOG("Cannot read DBus watch remove flag data from socket!\n");
     return;
   }
   short events = DBusFlagsToUnixEvents(flags);
   pollfd p;
   p.fd = removeFD;
   p.events = events;
   int index = aDbt->mPollData.IndexOf(p, 0, PollFdComparator());
+  // There are times where removes can be requested for watches that
+  // haven't been added (for example, whenever gecko comes up after
+  // adapters have already been enabled), so check to make sure we're
+  // using the watch in the first place
+  if(index < 0) {
+    LOG("DBus requested watch removal of non-existant socket, ignoring...");
+    return;
+  }
   aDbt->mPollData.RemoveElementAt(index);
 
   // DBusWatch pointers are maintained by DBus, so we won't leak by
   // removing.
   aDbt->mWatchData.RemoveElementAt(index);
 }
 
 // Called by dbus during WaitForAndDispatchEventNative()