From: John Thompson Date: Fri, 23 Oct 2009 02:21:17 +0000 (+0000) Subject: Fixed undefined behavior in pushMappings when the stack has to resize. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ca2c3e2cfc630db614298e8d7f2aaca4507e01e1;p=clang Fixed undefined behavior in pushMappings when the stack has to resize. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84924 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index d665e49126..fbc7313116 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -230,6 +230,8 @@ Diagnostic::~Diagnostic() { void Diagnostic::pushMappings() { + // Avoids undefined behavior when the stack has to resize. + DiagMappingsStack.reserve(DiagMappingsStack.size() + 1); DiagMappingsStack.push_back(DiagMappingsStack.back()); }