Array index : No recursive checking unless the "--all" has been given
This commit is contained in:
parent
df452a3b0f
commit
1f189f655d
|
@ -35,7 +35,8 @@
|
|||
// _callStack used when parsing into subfunctions.
|
||||
|
||||
|
||||
CheckBufferOverrunClass::CheckBufferOverrunClass( const Tokenizer *tokenizer, ErrorLogger *errorLogger )
|
||||
CheckBufferOverrunClass::CheckBufferOverrunClass( const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger )
|
||||
: _settings(settings)
|
||||
{
|
||||
_tokenizer = tokenizer;
|
||||
_errorLogger = errorLogger;
|
||||
|
@ -222,6 +223,10 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
|
|||
if (std::find(_callStack.begin(), _callStack.end(), tok) != _callStack.end())
|
||||
continue;
|
||||
|
||||
// Only perform this checking if showAll setting is enabled..
|
||||
if ( ! _settings._showAll )
|
||||
continue;
|
||||
|
||||
unsigned int parlevel = 0, par = 0;
|
||||
for ( const TOKEN *tok2 = tok; tok2; tok2 = tok2->next )
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
class CheckBufferOverrunClass
|
||||
{
|
||||
public:
|
||||
CheckBufferOverrunClass( const Tokenizer *tokenizer, ErrorLogger *errorLogger );
|
||||
CheckBufferOverrunClass( const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger );
|
||||
~CheckBufferOverrunClass();
|
||||
|
||||
// Buffer overrun..
|
||||
|
@ -44,6 +44,7 @@ private:
|
|||
void ReportError(const TOKEN *tok, const char errmsg[]);
|
||||
|
||||
const Tokenizer *_tokenizer;
|
||||
const Settings _settings;
|
||||
ErrorLogger *_errorLogger;
|
||||
std::list<const TOKEN *> _callStack;
|
||||
};
|
||||
|
|
|
@ -244,7 +244,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
|||
checkMemoryLeak.CheckMemoryLeak();
|
||||
|
||||
// Buffer overruns..
|
||||
CheckBufferOverrunClass checkBufferOverrun( &_tokenizer, this );
|
||||
CheckBufferOverrunClass checkBufferOverrun( &_tokenizer, _settings, this );
|
||||
checkBufferOverrun.CheckBufferOverrun();
|
||||
|
||||
// Check that all class constructors are ok.
|
||||
|
|
|
@ -51,7 +51,9 @@ private:
|
|||
errout.str("");
|
||||
|
||||
// Check for buffer overruns..
|
||||
CheckBufferOverrunClass checkBufferOverrun( &tokenizer, this );
|
||||
Settings settings;
|
||||
settings._showAll = true;
|
||||
CheckBufferOverrunClass checkBufferOverrun( &tokenizer, settings, this );
|
||||
checkBufferOverrun.CheckBufferOverrun();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue