Bug 753134 - B2G bluetooth interface crashes when trying to remove non-existent dbus watch sockets; r=mwu

This commit is contained in:
Kyle Machulis 2012-05-09 16:33:56 -07:00
parent 358d353bb9
commit 00223065fe

View File

@ -276,6 +276,14 @@ static void HandleWatchRemove(DBusThread* aDbt) {
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