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 | da6a21cdd2e138dcb7b578bf6161e9d1e24a11fa (patch) | |
| tree | 3ecd99016282d2cf7bfd1167f161d98367c85f6b /clang/lib/Serialization | |
| parent | 11191f11b8a4217f0a396ba0c6284cf4413f52e5 (diff) | |
| download | bcm5719-llvm-da6a21cdd2e138dcb7b578bf6161e9d1e24a11fa.tar.gz bcm5719-llvm-da6a21cdd2e138dcb7b578bf6161e9d1e24a11fa.zip | |
Fix a use of an invalidated reference due to a hash map reallocating.
llvm-svn: 114937
Diffstat (limited to 'clang/lib/Serialization')
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 1a42665d075..ee9cd1a4df7 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/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; |

