From e4eb9bfbf74385cb3ee5d7225814be697aa47285 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 27 Nov 2014 13:27:06 +0100 Subject: [PATCH] Break after handling the read/write The loop is there because watchers may have two Watcher for the same fd, one for read and one for write, but after we're processed the correct one we don't need to keep looping. This fixes a crash since it's possible that while in processing q_dbus_watch_handle we get a watch added/remove this invalidating the iterator and crashing Change-Id: Icb61deae272d2f237a4c616fae598404d419af90 Reviewed-by: Thiago Macieira --- src/dbus/qdbusintegrator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index f27d45b142..dd92602dce 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1184,6 +1184,7 @@ void QDBusConnectionPrivate::socketRead(int fd) if (it->watch && it->read && it->read->isEnabled()) { if (!q_dbus_watch_handle(it.value().watch, DBUS_WATCH_READABLE)) qDebug("OUT OF MEM"); + break; } ++it; } @@ -1198,6 +1199,7 @@ void QDBusConnectionPrivate::socketWrite(int fd) if (it->watch && it->write && it->write->isEnabled()) { if (!q_dbus_watch_handle(it.value().watch, DBUS_WATCH_WRITABLE)) qDebug("OUT OF MEM"); + break; } ++it; }