From 20e8c3be3ca1b24ddac51e4cfd67eba1cb551210 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 19 Jan 2015 10:51:42 +0000 Subject: clang-format: Fix crash on invalid code. Input "a<," made clang-format crash. llvm-svn: 226450 --- clang/lib/Format/FormatToken.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'clang/lib/Format/FormatToken.cpp') diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp index badb3a39c82..0addbfed0ce 100644 --- a/clang/lib/Format/FormatToken.cpp +++ b/clang/lib/Format/FormatToken.cpp @@ -59,7 +59,8 @@ void TokenRole::precomputeFormattingInfos(const FormatToken *Token) {} unsigned CommaSeparatedList::formatAfterToken(LineState &State, ContinuationIndenter *Indenter, bool DryRun) { - if (!State.NextToken->Previous || !State.NextToken->Previous->Previous) + if (State.NextToken == nullptr || !State.NextToken->Previous || + !State.NextToken->Previous->Previous) return 0; // Ensure that we start on the opening brace. -- cgit v1.2.3