CppEditor: Fix crash when calling CppModelManager::projectPart

find and end of QMap potentially detach the container, so we have to use
constFind and constEnd

Fixes: QTCREATORBUG-29716
Change-Id: I2fef46580ff5b58a70201841423e5ca0a7b4d107
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
David Schulz
2023-11-06 14:13:11 +01:00
parent c617d97c29
commit 05ce5ea14d

View File

@@ -1647,8 +1647,8 @@ QList<ProjectPart::ConstPtr> CppModelManager::projectPart(const FilePath &fileNa
{ {
{ {
QReadLocker locker(&d->m_projectLock); QReadLocker locker(&d->m_projectLock);
auto it = d->m_fileToProjectParts.find(fileName); auto it = d->m_fileToProjectParts.constFind(fileName);
if (it != d->m_fileToProjectParts.end()) if (it != d->m_fileToProjectParts.constEnd())
return it.value(); return it.value();
} }
const FilePath canonicalPath = fileName.canonicalPath(); const FilePath canonicalPath = fileName.canonicalPath();