diff options
author | Neil <nyamatongwe@gmail.com> | 2014-05-14 11:29:10 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2014-05-14 11:29:10 +1000 |
commit | a6b0119905484392eec48a2f067c6c0bb0d16acf (patch) | |
tree | eef87d73c963f61f1be2bf255722d5c614d7863f | |
parent | bdb2e90dd86303411c261b8cb8a8410f81a0f592 (diff) | |
download | scintilla-mirror-a6b0119905484392eec48a2f067c6c0bb0d16acf.tar.gz |
Limit iterations when expanding macros in case a macro is recursive such as
#define MAC(x) MAC(x+1)
Also fixes macros that are co-recursive with other macros.
-rw-r--r-- | lexers/LexCPP.cxx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx index d884c212f..9e99b5ce8 100644 --- a/lexers/LexCPP.cxx +++ b/lexers/LexCPP.cxx @@ -1412,7 +1412,10 @@ void LexerCPP::EvaluateTokens(std::vector<std::string> &tokens, const SymbolTabl } // Evaluate identifiers - for (size_t i=0; i<tokens.size();) { + const size_t maxIterations = 100; + size_t iterations = 0; // Limit number of iterations in case there is a recursive macro. + for (size_t i = 0; (i<tokens.size()) && (iterations < maxIterations);) { + iterations++; if (setWordStart.Contains(static_cast<unsigned char>(tokens[i][0]))) { SymbolTable::const_iterator it = preprocessorDefinitions.find(tokens[i]); if (it != preprocessorDefinitions.end()) { |