From: Rafael Espindola Date: Wed, 30 Jul 2014 02:37:26 +0000 (+0000) Subject: Fix a use after free bug. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=272a84656ecefec7a7438a1c2f8edadf198d8a35;p=clang Fix a use after free bug. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214281 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index c7685e4a6d..ea18d562b4 100644 --- a/lib/AST/ASTContext.cpp +++ b/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