diff options
author | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2010-09-26 16:38:55 (GMT) |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2010-09-26 16:46:14 (GMT) |
commit | 45c2ac4f1e1218f595b1d21691c8dec4eaa1a021 (patch) | |
tree | 0157ea8b572b5e88e954026a394a0d835d75cb37 /src/network/kernel | |
parent | 2a41640f3147acf801e5fdc7e6867b6cd93422a3 (diff) | |
download | Qt-45c2ac4f1e1218f595b1d21691c8dec4eaa1a021.zip Qt-45c2ac4f1e1218f595b1d21691c8dec4eaa1a021.tar.gz Qt-45c2ac4f1e1218f595b1d21691c8dec4eaa1a021.tar.bz2 |
QHostInfo: Fix a crash when a new request is pushed while resolving.
The loop looking for posponedLookup in the lookup thread wasn't locking
the mutex before trying to access/modify the list.
Reviewed-by: Andreas Kling
Diffstat (limited to 'src/network/kernel')
-rw-r--r-- | src/network/kernel/qhostinfo.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 348b0d2..41a9512 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -468,14 +468,17 @@ void QHostInfoRunnable::run() resultEmitter.emitResultsReady(hostInfo); // now also iterate through the postponed ones - QMutableListIterator<QHostInfoRunnable*> iterator(manager->postponedLookups); - while (iterator.hasNext()) { - QHostInfoRunnable* postponed = iterator.next(); - if (toBeLookedUp == postponed->toBeLookedUp) { - // we can now emit - iterator.remove(); - hostInfo.setLookupId(postponed->id); - postponed->resultEmitter.emitResultsReady(hostInfo); + { + QMutexLocker locker(&manager->mutex); + QMutableListIterator<QHostInfoRunnable*> iterator(manager->postponedLookups); + while (iterator.hasNext()) { + QHostInfoRunnable* postponed = iterator.next(); + if (toBeLookedUp == postponed->toBeLookedUp) { + // we can now emit + iterator.remove(); + hostInfo.setLookupId(postponed->id); + postponed->resultEmitter.emitResultsReady(hostInfo); + } } } |