diff options
author | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2010-09-26 16:38:55 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2010-09-27 08:52:09 (GMT) |
commit | 6529e1df5279e44e93c7f18333103658257c92d7 (patch) | |
tree | 77303b703d5b997b9d00d43958ac84a17ab08a4e | |
parent | 01de6e56c95e43fbbc8b645afbcf37e01a385740 (diff) | |
download | Qt-6529e1df5279e44e93c7f18333103658257c92d7.zip Qt-6529e1df5279e44e93c7f18333103658257c92d7.tar.gz Qt-6529e1df5279e44e93c7f18333103658257c92d7.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
(cherry picked from commit 45c2ac4f1e1218f595b1d21691c8dec4eaa1a021)
-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); + } } } |