From 50d9a085da1426074c95fd21d8195fabccc70290 Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Sun, 18 Jan 2009 22:46:48 +0000 Subject: [PATCH] Added temporary bailout code, cppcheck crashes when string checking leaks out. This needs a better fix, this is just to see the problem more easily. --- src/checkother.cpp | 4 ++-- src/preprocessor.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/checkother.cpp b/src/checkother.cpp index 7e1fef77b..d4854af73 100644 --- a/src/checkother.cpp +++ b/src/checkother.cpp @@ -818,8 +818,8 @@ void CheckOther::unreachableCode() break; // If there is a statement below the return it is unreachable - if ( !Token::Match(tok, "; case|default|}|#") && !Token::Match(tok, "; %var% :") - && ( _settings._checkCodingStyle || !Token::simpleMatch(tok, "; break") ) ) + if (!Token::Match(tok, "; case|default|}|#") && !Token::Match(tok, "; %var% :") + && (_settings._checkCodingStyle || !Token::simpleMatch(tok, "; break"))) { _errorLogger->reportErr(ErrorMessage::unreachableCode(_tokenizer, tok->next())); } diff --git a/src/preprocessor.cpp b/src/preprocessor.cpp index 7cf2038fd..a52a56627 100644 --- a/src/preprocessor.cpp +++ b/src/preprocessor.cpp @@ -610,7 +610,7 @@ public: }; - +#include std::string Preprocessor::expandMacros(std::string code) { @@ -668,6 +668,14 @@ std::string Preprocessor::expandMacros(std::string code) if (code[pos1] == '\\') ++pos1; ++pos1; + + if (!code[pos1]) + { + // TODO, this code is here, because there is currently a bug in cppcheck + // Once it has been sorted out, this if can be removed + std::cout << "\n\n####### There is a bug in preprocessor.cpp that can cause crash, shutting down.\n\n" << std::endl; + exit(0); + } } continue; }