preprocessor: Bail out the expandMacros if it finds "#undef". The previous handling can cause cppcheck to hang

This commit is contained in:
Daniel Marjamäki 2009-01-14 19:50:17 +00:00
parent 03cfe18c9b
commit a01c5a6099
1 changed files with 4 additions and 0 deletions

View File

@ -449,6 +449,10 @@ std::string Preprocessor::getcode(const std::string &filedata, std::string cfg)
std::string Preprocessor::expandMacros(std::string code)
{
// Bail out if there are "#undef" it can cause cppcheck to hang
if (code.find("#undef") != std::string::npos)
return code;
// Search for macros and expand them..
std::string::size_type defpos = 0;
while ((defpos = code.find("#define ", defpos)) != std::string::npos)