diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-09-28 02:24:44 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-09-28 02:24:44 +0000 |
commit | 4a9eb26500086f913c4683bb360b14f8ce662fb4 (patch) | |
tree | 98ef88b75bca34ec2c136426b543ea1027d84817 /lib/Serialization/ASTReader.cpp | |
parent | 28cab383fd9e7647d2186340eca769303cc4fbdb (diff) |
Fix a use of an invalidated reference due to a hash map reallocating.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114937 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTReader.cpp')
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 1a42665d07..ee9cd1a4df 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -3180,7 +3180,9 @@ bool ASTReader::FindExternalLexicalDecls(const DeclContext *DC, // There might be lexical decls in multiple parts of the chain, for the TU // at least. - DeclContextInfos &Infos = DeclContextOffsets[DC]; + // DeclContextOffsets might reallocate as we load additional decls below, + // so make a copy of the vector. + DeclContextInfos Infos = DeclContextOffsets[DC]; for (DeclContextInfos::iterator I = Infos.begin(), E = Infos.end(); I != E; ++I) { // IDs can be 0 if this context doesn't contain declarations. @@ -3190,8 +3192,11 @@ bool ASTReader::FindExternalLexicalDecls(const DeclContext *DC, // Load all of the declaration IDs for (const DeclID *ID = I->LexicalDecls, *IDE = ID + I->NumLexicalDecls; - ID != IDE; ++ID) - Decls.push_back(GetDecl(*ID)); + ID != IDE; ++ID) { + Decl *D = GetDecl(*ID); + assert(D && "Null decl in lexical decls"); + Decls.push_back(D); + } } ++NumLexicalDeclContextsRead; |