Fix ticket #239 (missing function implementation in namespace causes crash)

http://apps.sourceforge.net/trac/cppcheck/ticket/239
This commit is contained in:
Reijo Tomperi 2009-03-31 00:59:33 +03:00
parent 263c5b9e5a
commit 14bdf1ee62
2 changed files with 12 additions and 1 deletions

View File

@ -725,7 +725,7 @@ void Tokenizer::simplifyNamespaces()
{
for (Token *token = _tokens; token; token = token->next())
{
while (token->str() == "namespace" &&
while (token && token->str() == "namespace" &&
(!token->previous() || token->previous()->str() != "using"))
{
// Token is namespace and there is no "using" before it.
@ -759,6 +759,9 @@ void Tokenizer::simplifyNamespaces()
return;
}
}
if (!token)
break;
}
}

View File

@ -557,6 +557,14 @@ private:
ASSERT_EQUALS(expected, sizeof_(code));
}
{
const char code[] = "int a; namespace b{ }";
const std::string expected(" int a ;");
ASSERT_EQUALS(expected, sizeof_(code));
}
}