]> granicus.if.org Git - clang/commitdiff
clang-format: Fix invalid write discovered by ASAN.
authorDaniel Jasper <djasper@google.com>
Mon, 23 Dec 2013 11:25:40 +0000 (11:25 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 23 Dec 2013 11:25:40 +0000 (11:25 +0000)
Introduced in r197900.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197906 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/ContinuationIndenter.cpp

index 7b3f5cb67fe44763c0f3e50ce388ebb30d53edfc..d4bf6ecfa915f6bdb4b426ac4d17c66d3e428de1 100644 (file)
@@ -421,7 +421,8 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
     //                        }];
     // Thus, we set LastSpace of the next higher ParenLevel, to which we move
     // when we consume all of the "}"'s FakeRParens at the "{".
-    State.Stack[State.Stack.size() - 2].LastSpace = ContinuationIndent;
+    if (State.Stack.size() > 1)
+      State.Stack[State.Stack.size() - 2].LastSpace = ContinuationIndent;
   } else if (Current.Type == TT_CtorInitializerColon) {
     State.Column = State.FirstIndent + Style.ConstructorInitializerIndentWidth;
   } else if (Current.Type == TT_CtorInitializerComma) {