diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-07-30 02:37:26 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-07-30 02:37:26 +0000 |
commit | e122ee1fab44b2bd904c944b0152d9b3bd2464ef (patch) | |
tree | fcdbd54d46c50b992116f76adee39fefe30fcb19 /clang/lib/AST/ASTContext.cpp | |
parent | d2aac5795e3fdb2e1efbb5097b2ec4f771545ff8 (diff) | |
download | bcm5719-llvm-e122ee1fab44b2bd904c944b0152d9b3bd2464ef.tar.gz bcm5719-llvm-e122ee1fab44b2bd904c944b0152d9b3bd2464ef.zip |
Fix a use after free bug.
llvm-svn: 214281
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index c7685e4a6dd..ea18d562b43 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1432,11 +1432,14 @@ bool ASTContext::isAlignmentRequired(QualType T) const { } TypeInfo ASTContext::getTypeInfo(const Type *T) const { - TypeInfo &TI = MemoizedTypeInfo[T]; - if (!TI.Align) - TI = getTypeInfoImpl(T); - - return TI; + TypeInfo TI = MemoizedTypeInfo[T]; + if (TI.Align) + return TI; + + // This call can invalidate TI, so we need a second lookup. + TypeInfo Temp = getTypeInfoImpl(T); + MemoizedTypeInfo[T] = Temp; + return Temp; } /// getTypeInfoImpl - Return the size of the specified type, in bits. This |