Skip to content

Commit

Permalink
[connectionagent] Ensure dangling pointers are not left in services map.
Browse files Browse the repository at this point in the history
NetworkServices were only ever added to servicesMap, never removed.
Except on Connman availability changed. Iterating over the map could
result in dereferencing dangling pointers.
  • Loading branch information
Aaron McCarthy committed May 1, 2014
1 parent e6292a7 commit adb238b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions connd/qconnectionagent.cpp
Expand Up @@ -291,6 +291,7 @@ void QConnectionAgent::updateServicesMap()
qDebug() << Q_FUNC_INFO;
QStringList oldServices = orderedServicesList;
orderedServicesList.clear();
servicesMap.clear();

Q_FOREACH (const QString &tech,techPreferenceList) {
QVector<NetworkService*> services = netman->getServices(tech);
Expand Down Expand Up @@ -407,6 +408,7 @@ void QConnectionAgent::serviceRemoved(const QString &srv)
qDebug() << Q_FUNC_INFO << "<<<<" << srv;
if (orderedServicesList.contains(srv)) {
orderedServicesList.removeOne(srv);
servicesMap.remove(srv);
}
}

Expand Down

0 comments on commit adb238b

Please sign in to comment.