Skip to content

Commit

Permalink
CXX: Avoid assert with broken input in debug builds (#3056)
Browse files Browse the repository at this point in the history
  • Loading branch information
pragmaware authored Jun 8, 2021
1 parent cab9828 commit d377176
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions parsers/cxx/cxx_parser_tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,8 @@ static bool cxxParserParseNextTokenCondenseCXX11Attribute(void)
"This function should be called only after we have parsed ["
);

// Input stream: [[foo]]...
// Input stream: [[...
// If the syntax is correct then this is an attribute sequence [[foo]]
//
// g_cxx.pToken points the first '['.
// g_cxx.iChar points the second '['.
Expand Down Expand Up @@ -1037,7 +1038,8 @@ static bool cxxParserParseNextTokenCondenseCXX11Attribute(void)
"Should have a parenthesis chain as last token!"
);
CXX_DEBUG_ASSERT(
(g_cxx.pToken->pChain->iCount == 3) &&
// at least [ + [*] + ]
(g_cxx.pToken->pChain->iCount >= 3) &&
cxxTokenTypeIs(
cxxTokenChainAt(g_cxx.pToken->pChain,1),
CXXTokenTypeSquareParenthesisChain
Expand Down

0 comments on commit d377176

Please sign in to comment.