TopContextDynamicData: Fix bug in loadPartialData
Detected using ASAN
Regression introduced by 49e4b656f0e54bff882f03efe04feedff5994ed1
31328==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x60b0007dc6e4 at pc 0x7f8c81dd210f bp 0x7ffc0dba13f0 sp 0x7ffc0dba13e8
READ of size 8 at 0x60b0007dc6e4 thread T0
#0 0x7f8c81dd210e in
QList<KDevelop::IndexedDUContext>::node_construct(QList<KDevelop::IndexedDUContext>::Node*,
KDevelop::IndexedDUContext const&)
/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:405:39
#1 0x7f8c81dd210e in
QList<KDevelop::IndexedDUContext>::append(KDevelop::IndexedDUContext
const&) /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:569
#2 0x7f8c81dd210e in
QList<KDevelop::IndexedDUContext>::operator<<(KDevelop::IndexedDUContext
const&) /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:355
#3 0x7f8c81dd210e in
KDevelop::TopDUContextDynamicData::loadImporters(unsigned
int)::$_0::operator()(KDevelop::TopDUContextData const*) const
/home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/topducontextdynamicdata.cpp:505
#4 0x7f8c81dd210e in void (anonymous
namespace)::loadPartialData<KDevelop::TopDUContextDynamicData::loadImporters(unsigned
int)::$_0>(unsigned int,
KDevelop::TopDUContextDynamicData::loadImporters(unsigned int)::$_0)
/home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/topducontextdynamicdata.cpp:175
#5 0x7f8c81dd210e in
KDevelop::TopDUContextDynamicData::loadImporters(unsigned int)
/home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/topducontextdynamicdata.cpp:502
#6 0x7f8c81e7bc8d in KDevelop::ParsingEnvironmentFile::importers()
const
/home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/parsingenvironment.cpp:205:11
#7 0x7f8c81d42a12 in
KDevelop::DUChainPrivate::addContextsForRemoval(QSet<unsigned int>&,
KDevelop::IndexedTopDUContext)
/home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/duchain.cpp:1015:81
#8 0x7f8c81d12dd6 in KDevelop::DUChainPrivate::cleanupTopContexts()
/home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/duchain.cpp:985:9
#9 0x7f8c81d08f64 in KDevelop::DUChain::shutdown()
/home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/duchain.cpp:1572:5
#10 0x7f8c8a4e6c07 in KDevelop::Core::cleanup()
/home/kfunk/devel/src/kf5/kdevplatform-stable/shell/core.cpp:454:9
#11 0x7f8c8a4e5add in KDevelop::Core::shutdown()
...
AddressSanitizer can not describe address in more detail (wild memory
access suspected).
SUMMARY: AddressSanitizer: heap-buffer-overflow
/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:405
QList<KDevelop::IndexedDUContext>::node_construct(QList<KDevelop::IndexedDUContext>::Node*,
KDevelop::IndexedDUContext const&)
Differential Revision: https://phabricator.kde.org/D845