PP: Fix issue #407; handle empty identifier.

The sequence

  #define m()
  int m"

creates a token of no length (a string of 0 size).  Protect
against a string of 0 size as well as the existing protect
against a null string.
This commit is contained in:
John Kessenich 2016-07-30 13:39:52 -06:00
parent 7208473c69
commit 11e1a073f3
4 changed files with 11 additions and 4 deletions

View file

@ -612,13 +612,15 @@ void TScanContext::deleteKeywordMap()
ReservedSet = nullptr;
}
// Called by yylex to get the next token.
// Returning 0 implies end of input.
int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
{
do {
parserToken = &token;
TPpToken ppToken;
tokenText = pp->tokenize(&ppToken);
if (tokenText == nullptr)
if (tokenText == nullptr || tokenText[0] == 0)
return 0;
loc = ppToken.loc;