forked from qt-creator/qt-creator
Utils: Fix theoretical use-after-free
Change-Id: I909f2dcd71c2286036f43fce6fc8aa61c55a6695 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -40,7 +40,13 @@ public:
|
|||||||
if (!data) {
|
if (!data) {
|
||||||
data = new CachedData;
|
data = new CachedData;
|
||||||
*data = retrievalFunction(filePath);
|
*data = retrievalFunction(filePath);
|
||||||
m_cache.insert(filePath, data);
|
if (Q_UNLIKELY(!m_cache.insert(filePath, data))) {
|
||||||
|
// This path will never happen, but to silence coverity we
|
||||||
|
// have to check it since insert in theory could delete
|
||||||
|
// the object if a cost bigger than the cache size is
|
||||||
|
// specified.
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a copy of the data, so it cannot be deleted by the cache
|
// Return a copy of the data, so it cannot be deleted by the cache
|
||||||
|
|||||||
Reference in New Issue
Block a user