]> granicus.if.org Git - clang/commitdiff
Fixed undefined behavior in pushMappings when the stack has to resize.
authorJohn Thompson <John.Thompson.JTSoftware@gmail.com>
Fri, 23 Oct 2009 02:21:17 +0000 (02:21 +0000)
committerJohn Thompson <John.Thompson.JTSoftware@gmail.com>
Fri, 23 Oct 2009 02:21:17 +0000 (02:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84924 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Diagnostic.cpp

index d665e49126d3bb1f1f8baeb2a5dbbf29faf0a6f5..fbc7313116531099437b66cc8098e74d234ec88a 100644 (file)
@@ -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());
 }